mirror of
https://github.com/denoland/deno.git
synced 2025-01-08 15:19:40 -05:00
fix(op_crates/web/url): apply backslash replacement to the pathname setter (#7937)
This commit is contained in:
parent
bbf7b2ee72
commit
d0c2714c03
2 changed files with 6 additions and 2 deletions
|
@ -192,6 +192,8 @@ unitTest(function urlModifyPathname(): void {
|
||||||
// deno-lint-ignore no-self-assign
|
// deno-lint-ignore no-self-assign
|
||||||
url.pathname = url.pathname;
|
url.pathname = url.pathname;
|
||||||
assertEquals(url.pathname, "/baz%23qat%20qux");
|
assertEquals(url.pathname, "/baz%23qat%20qux");
|
||||||
|
url.pathname = "\\a\\b\\c";
|
||||||
|
assertEquals(url.pathname, "/a/b/c");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function urlModifyHash(): void {
|
unitTest(function urlModifyHash(): void {
|
||||||
|
|
|
@ -378,7 +378,7 @@
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
[parts.path, restUrl] = takePattern(restUrl, /^([^?#]*)/);
|
[parts.path, restUrl] = takePattern(restUrl, /^([^?#]*)/);
|
||||||
parts.path = encodePathname(parts.path.replace(/\\/g, "/"));
|
parts.path = encodePathname(parts.path);
|
||||||
if (usedNonBase) {
|
if (usedNonBase) {
|
||||||
parts.path = normalizePath(parts.path, parts.protocol == "file");
|
parts.path = normalizePath(parts.path, parts.protocol == "file");
|
||||||
} else {
|
} else {
|
||||||
|
@ -870,7 +870,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function encodePathname(s) {
|
function encodePathname(s) {
|
||||||
return [...s].map((c) => (charInPathSet(c) ? encodeChar(c) : c)).join("");
|
return [...s.replace(/\\/g, "/")].map((
|
||||||
|
c,
|
||||||
|
) => (charInPathSet(c) ? encodeChar(c) : c)).join("");
|
||||||
}
|
}
|
||||||
|
|
||||||
function encodeSearch(s, isSpecial) {
|
function encodeSearch(s, isSpecial) {
|
||||||
|
|
Loading…
Reference in a new issue