From 0321aba0dae1e3452b862ef9c8d5c569eaa7d615 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Sat, 22 Jul 2023 11:22:24 -0700 Subject: [PATCH] utils: perform portable path sanitisation of URLs Some file systems have restrictions on character sets which are valid file name characters. Add a filter for the Windows file system character set restrictions. We replace them with `_` to match the behaviour in the DocC bundle generation after apple/swift-docc#668. --- src/utils/data.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/data.js b/src/utils/data.js index fc1440457..6547f2d1b 100644 --- a/src/utils/data.js +++ b/src/utils/data.js @@ -56,7 +56,7 @@ export async function fetchData(path, params = {}, options = {}) { } function createDataPath(path) { - const dataPath = path.replace(/\/$/, ''); + const dataPath = path.replace(/\/$/, "").replace(/[<>:"\/\\|*]/, "_"); return `${normalizePath(['/data', dataPath])}.json`; }