summaryrefslogtreecommitdiff
path: root/cli/rt
diff options
context:
space:
mode:
Diffstat (limited to 'cli/rt')
-rw-r--r--cli/rt/11_url.js15
1 files changed, 9 insertions, 6 deletions
diff --git a/cli/rt/11_url.js b/cli/rt/11_url.js
index a7200f11c..7e01f4d88 100644
--- a/cli/rt/11_url.js
+++ b/cli/rt/11_url.js
@@ -370,7 +370,7 @@
}
if (usedNonBase || restUrl.startsWith("?")) {
[parts.query, restUrl] = takePattern(restUrl, /^(\?[^#]*)/);
- parts.query = encodeSearch(parts.query);
+ parts.query = encodeSearch(parts.query, isSpecial);
usedNonBase = true;
} else {
parts.query = baseParts.query;
@@ -660,7 +660,8 @@
set search(value) {
value = String(value);
const query = value == "" || value.charAt(0) == "?" ? value : `?${value}`;
- parts.get(this).query = encodeSearch(query);
+ const isSpecial = specialSchemes.includes(parts.get(this).protocol);
+ parts.get(this).query = encodeSearch(query, isSpecial);
this.#updateSearchParams();
}
@@ -766,9 +767,9 @@
return (c >= "\u0000" && c <= "\u001F") || c > "\u007E";
}
- function charInSearchSet(c) {
+ function charInSearchSet(c, isSpecial) {
// deno-fmt-ignore
- return charInC0ControlSet(c) || ["\u0020", "\u0022", "\u0023", "\u0027", "\u003C", "\u003E"].includes(c) || c > "\u007E";
+ return charInC0ControlSet(c) || ["\u0020", "\u0022", "\u0023", "\u003C", "\u003E"].includes(c) || isSpecial && c == "\u0027" || c > "\u007E";
}
function charInFragmentSet(c) {
@@ -871,8 +872,10 @@
return [...s].map((c) => (charInPathSet(c) ? encodeChar(c) : c)).join("");
}
- function encodeSearch(s) {
- return [...s].map((c) => (charInSearchSet(c) ? encodeChar(c) : c)).join("");
+ function encodeSearch(s, isSpecial) {
+ return [...s].map((
+ c,
+ ) => (charInSearchSet(c, isSpecial) ? encodeChar(c) : c)).join("");
}
function encodeHash(s) {