summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/tests/unit/url_search_params_test.ts6
-rw-r--r--op_crates/web/11_url.js2
2 files changed, 7 insertions, 1 deletions
diff --git a/cli/tests/unit/url_search_params_test.ts b/cli/tests/unit/url_search_params_test.ts
index 96b524265..41b277129 100644
--- a/cli/tests/unit/url_search_params_test.ts
+++ b/cli/tests/unit/url_search_params_test.ts
@@ -179,6 +179,12 @@ unitTest(function urlSearchParamsMissingPair(): void {
assertEquals(searchParams.toString(), "c=4&a=54");
});
+unitTest(function urlSearchParamsForShortEncodedChar(): void {
+ const init = { linefeed: "\n", tab: "\t" };
+ const searchParams = new URLSearchParams(init);
+ assertEquals(searchParams.toString(), "linefeed=%0A&tab=%09");
+});
+
// If pair does not contain exactly two items, then throw a TypeError.
// ref https://url.spec.whatwg.org/#interface-urlsearchparams
unitTest(function urlSearchParamsShouldThrowTypeError(): void {
diff --git a/op_crates/web/11_url.js b/op_crates/web/11_url.js
index fb5bece25..fe7ef041a 100644
--- a/op_crates/web/11_url.js
+++ b/op_crates/web/11_url.js
@@ -803,7 +803,7 @@
function encodeChar(c) {
return [...encoder.encode(c)]
- .map((n) => `%${n.toString(16)}`)
+ .map((n) => `%${n.toString(16).padStart(2, "0")}`)
.join("")
.toUpperCase();
}