0
0
mirror of https://github.com/rkd77/elinks.git synced 2025-09-21 19:46:23 -04:00
Files
elinks/test/js/assert/URLSearchParams.html

33 lines
808 B
HTML
Raw Normal View History

2024-06-12 14:25:24 +02:00
<script>
console.error("URLSearchParams.html");
2024-06-14 21:24:14 +02:00
2024-06-14 21:28:36 +02:00
var empty = new URLSearchParams('');
console.assert(empty.size === 0, 'empty');
2024-06-14 21:24:14 +02:00
var param = new URLSearchParams('?foo=1&bar=2&cc=3');
console.assert(param.size === 3, 'size is 3');
2024-06-12 14:25:24 +02:00
console.assert(param.has('foo'), 'foo');
2024-06-14 21:24:14 +02:00
console.assert(param.has('cc'), 'cc');
2024-06-12 14:25:24 +02:00
console.assert(param.has('bar', '2'), 'bar=2');
console.assert(param.get('bar') === '2', 'bar = 2');
2024-06-14 21:24:14 +02:00
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'));
2024-06-12 14:25:24 +02:00
console.exit();
</script>