diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2020-08-21 14:37:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-21 15:37:06 +0200 |
commit | cf603be24cdc92b6758c602c005f37f4d5f6c5b6 (patch) | |
tree | 4e0d0212a44ad8af3a777cebf65bf266e5c06523 /cli/rt/06_util.js | |
parent | fd83df7cdb983030ba111a1e19ad6c9ef5eb6128 (diff) |
fix: Allow isolated "%"s when parsing file URLs (#7108)
Diffstat (limited to 'cli/rt/06_util.js')
-rw-r--r-- | cli/rt/06_util.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/cli/rt/06_util.js b/cli/rt/06_util.js index 3570cb1fa..b0ed5696f 100644 --- a/cli/rt/06_util.js +++ b/cli/rt/06_util.js @@ -63,11 +63,13 @@ }); } + // Keep in sync with `fromFileUrl()` in `std/path/win32.ts`. function pathFromURLWin32(url) { let path = decodeURIComponent( url.pathname .replace(/^\/*([A-Za-z]:)(\/|$)/, "$1/") - .replace(/\//g, "\\"), + .replace(/\//g, "\\") + .replace(/%(?![0-9A-Fa-f]{2})/g, "%25"), ); if (url.hostname != "") { // Note: The `URL` implementation guarantees that the drive letter and @@ -78,12 +80,15 @@ return path; } + // Keep in sync with `fromFileUrl()` in `std/path/posix.ts`. function pathFromURLPosix(url) { if (url.hostname !== "") { throw new TypeError(`Host must be empty.`); } - return decodeURIComponent(url.pathname); + return decodeURIComponent( + url.pathname.replace(/%(?![0-9A-Fa-f]{2})/g, "%25"), + ); } function pathFromURL(pathOrUrl) { |