File: URLSearchParams.html

package info (click to toggle)
elinks 0.19.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 24,296 kB
  • sloc: ansic: 174,602; cpp: 31,967; sh: 7,841; python: 4,039; perl: 2,183; javascript: 1,794; pascal: 1,710; makefile: 1,006; yacc: 295; lisp: 125; awk: 79; ruby: 70
file content (32 lines) | stat: -rw-r--r-- 808 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<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>