diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a0f5e5..1efb96c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ ## Changelog +- 2.11.4 + - fixed encoded source url issue + - 2.11.3 - fixed cli to support `merge` command diff --git a/lib/utils/source-path.js b/lib/utils/source-path.js index 6dda027..a2e6f96 100644 --- a/lib/utils/source-path.js +++ b/lib/utils/source-path.js @@ -56,13 +56,23 @@ const filterPath = (str) => { return ls.join('/'); }; +const betterFileURLToPath = (url) => { + try { + url = fileURLToPath(url); + } catch (e) { + url = decodeURIComponent(url); + url = fileURLToPath(url); + } + return url; +}; + const normalizeSourcePath = (sourceUrl, baseDir) => { // includes anonymous and everything // file url if (sourceUrl.startsWith('file:')) { - const relPath = Util.relativePath(fileURLToPath(sourceUrl), baseDir); + const relPath = Util.relativePath(betterFileURLToPath(sourceUrl), baseDir); return filterPath(relPath); } @@ -108,7 +118,7 @@ const normalizeSourcePath = (sourceUrl, baseDir) => { // relative path const fileUrl = pathToFileURL(sourceUrl).toString(); - const relPath = Util.relativePath(fileURLToPath(fileUrl), baseDir); + const relPath = Util.relativePath(betterFileURLToPath(fileUrl), baseDir); return filterPath(relPath); };