mirror of
https://github.com/denoland/deno.git
synced 2025-01-08 15:19:40 -05:00
URLSearchParams
deleting appended multiple (#2201)
This commit is contained in:
parent
7fc9d7d62a
commit
8578ed4e7f
2 changed files with 16 additions and 1 deletions
|
@ -32,7 +32,7 @@ export class URLSearchParams {
|
|||
*/
|
||||
append(name: string, value: string): void {
|
||||
requiredArguments("URLSearchParams.append", arguments.length, 2);
|
||||
this.params.push([String(name), value]);
|
||||
this.params.push([String(name), String(value)]);
|
||||
}
|
||||
|
||||
/** Deletes the given search parameter and its associated value,
|
||||
|
@ -112,6 +112,7 @@ export class URLSearchParams {
|
|||
// set the value of the first such name-value pair to value
|
||||
// and remove the others.
|
||||
name = String(name);
|
||||
value = String(value);
|
||||
let found = false;
|
||||
let i = 0;
|
||||
while (i < this.params.length) {
|
||||
|
|
|
@ -182,3 +182,17 @@ test(function urlSearchParamsAppendArgumentsCheck(): void {
|
|||
}
|
||||
);
|
||||
});
|
||||
|
||||
// ref: https://github.com/web-platform-tests/wpt/blob/master/url/urlsearchparams-delete.any.js
|
||||
test(function urlSearchParamsDeletingAppendedMultiple(): void {
|
||||
const params = new URLSearchParams();
|
||||
params.append("first", (1 as unknown) as string);
|
||||
assert(params.has("first"));
|
||||
assertEquals(params.get("first"), "1");
|
||||
params.delete("first");
|
||||
assertEquals(params.has("first"), false);
|
||||
params.append("first", (1 as unknown) as string);
|
||||
params.append("first", (10 as unknown) as string);
|
||||
params.delete("first");
|
||||
assertEquals(params.has("first"), false);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue