mirror of
https://github.com/denoland/deno.git
synced 2024-12-25 08:39:09 -05:00
642c4a44a5
Fixes https://github.com/denoland/deno/issues/21734 Changes: - Use default encode when options do not provide a encode callback. - Remove internal TS for `node:querystring`. Its not helping catching bugs like this because of invalid type assumptions and use of `any`, more of a maintenance burden.
51 lines
965 B
TypeScript
51 lines
965 B
TypeScript
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
import { assertEquals } from "../../../test_util/std/assert/mod.ts";
|
|
import { parse, stringify } from "node:querystring";
|
|
|
|
Deno.test({
|
|
name: "stringify",
|
|
fn() {
|
|
assertEquals(
|
|
stringify({
|
|
a: "hello",
|
|
b: 5,
|
|
c: true,
|
|
d: ["foo", "bar"],
|
|
}),
|
|
"a=hello&b=5&c=true&d=foo&d=bar",
|
|
);
|
|
},
|
|
});
|
|
|
|
Deno.test({
|
|
name: "parse",
|
|
fn() {
|
|
assertEquals(parse("a=hello&b=5&c=true&d=foo&d=bar"), {
|
|
a: "hello",
|
|
b: "5",
|
|
c: "true",
|
|
d: ["foo", "bar"],
|
|
});
|
|
},
|
|
});
|
|
|
|
// https://github.com/denoland/deno/issues/21734
|
|
Deno.test({
|
|
name: "stringify options no encode",
|
|
fn() {
|
|
assertEquals(
|
|
stringify(
|
|
{
|
|
a: "hello",
|
|
b: 5,
|
|
c: true,
|
|
d: ["foo", "bar"],
|
|
},
|
|
"&",
|
|
"=",
|
|
{},
|
|
),
|
|
"a=hello&b=5&c=true&d=foo&d=bar",
|
|
);
|
|
},
|
|
});
|