Fix prelude/url (#7855)
This commit is contained in:
parent
bd9df789d1
commit
a73a787753
|
@ -4,7 +4,7 @@ export function query(obj: {}): string {
|
||||||
.reduce((a, [k, v]) => (a[k] = v, a), {} as Record<string, any>);
|
.reduce((a, [k, v]) => (a[k] = v, a), {} as Record<string, any>);
|
||||||
|
|
||||||
return Object.entries(params)
|
return Object.entries(params)
|
||||||
.map((e) => `${e[0]}=${e[1]}`)
|
.map((e) => `${e[0]}=${encodeURIComponent(e[1])}`)
|
||||||
.join('&');
|
.join('&');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
import * as assert from 'assert';
|
||||||
|
import { query } from '../../src/prelude/url';
|
||||||
|
|
||||||
|
describe('url', () => {
|
||||||
|
it('query', () => {
|
||||||
|
const s = query({
|
||||||
|
foo: 'ふぅ',
|
||||||
|
bar: 'b a r',
|
||||||
|
baz: undefined
|
||||||
|
});
|
||||||
|
assert.deepStrictEqual(s, 'foo=%E3%81%B5%E3%81%85&bar=b%20a%20r');
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue