Skip to content

Commit

Permalink
fix(op_crate/web): add padding on URLSearchParam (denoland#7905)
Browse files Browse the repository at this point in the history
  • Loading branch information
lala7573 authored and iykekings committed Oct 10, 2020
1 parent 80c285e commit 57496b8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions cli/tests/unit/url_search_params_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion op_crates/web/11_url.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 57496b8

Please sign in to comment.