mirror of
https://github.com/rkd77/elinks.git
synced 2025-06-30 22:19:29 -04:00
33 lines
808 B
HTML
33 lines
808 B
HTML
<script>
|
|
console.error("URLSearchParams.html");
|
|
|
|
var empty = new URLSearchParams('');
|
|
console.assert(empty.size === 0, 'empty');
|
|
|
|
var param = new URLSearchParams('?foo=1&bar=2&cc=3');
|
|
console.assert(param.size === 3, 'size is 3');
|
|
console.assert(param.has('foo'), 'foo');
|
|
console.assert(param.has('cc'), 'cc');
|
|
console.assert(param.has('bar', '2'), 'bar=2');
|
|
console.assert(param.get('bar') === '2', 'bar = 2');
|
|
console.assert(param.toString() === 'foo=1&bar=2&cc=3', 'without ?');
|
|
|
|
var params3 = new URLSearchParams([
|
|
["foo", "a1"],
|
|
["bar", "a2"],
|
|
["baz", "a3"],
|
|
]);
|
|
console.assert(params3.get('bar') === 'a2', 'bar = a2');
|
|
|
|
var params4 = new URLSearchParams({
|
|
foo : "c1",
|
|
bar : "c2",
|
|
baz : "c3",
|
|
});
|
|
console.assert(params4.get('bar') === 'c2', params4.get('bar'));
|
|
|
|
|
|
|
|
console.exit();
|
|
</script>
|