mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 15:24:46 -05:00
Fix handling of multiple spaces in URLSearchParams (#7068)
This ensures that all spaces are set to be "+" in the string rather than just the first and brings deno into line with how browsers handle spaces in URLSearchParams, see #7001.
This commit is contained in:
parent
68e1ba07d3
commit
1f7d4089f9
2 changed files with 4 additions and 4 deletions
|
@ -883,7 +883,7 @@
|
|||
|
||||
function encodeSearchParam(s) {
|
||||
return [...s].map((c) => (charInFormUrlencodedSet(c) ? encodeChar(c) : c))
|
||||
.join("").replace("%20", "+");
|
||||
.join("").replace(/%20/g, "+");
|
||||
}
|
||||
|
||||
window.__bootstrap.url = {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
import { unitTest, assert, assertEquals } from "./test_util.ts";
|
||||
|
||||
unitTest(function urlSearchParamsWithSpace(): void {
|
||||
const init = { str: "hello world" };
|
||||
unitTest(function urlSearchParamsWithMultipleSpaces(): void {
|
||||
const init = { str: "this string has spaces in it" };
|
||||
const searchParams = new URLSearchParams(init).toString();
|
||||
assertEquals(searchParams, "str=hello+world");
|
||||
assertEquals(searchParams, "str=this+string+has+spaces+in+it");
|
||||
});
|
||||
|
||||
unitTest(function urlSearchParamsWithExclamation(): void {
|
||||
|
|
Loading…
Reference in a new issue