• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3// Tests below are not from WPT.
4
5require('../common');
6const assert = require('assert');
7const URLSearchParams = require('url').URLSearchParams;
8
9{
10  const params = new URLSearchParams();
11  assert.throws(() => {
12    params.toString.call(undefined);
13  }, {
14    code: 'ERR_INVALID_THIS',
15    name: 'TypeError',
16    message: 'Value of "this" must be of type URLSearchParams'
17  });
18}
19
20// The URLSearchParams stringifier mutates the base URL using
21// different percent-encoding rules than the URL itself.
22{
23  const myUrl = new URL('https://example.org?foo=~bar');
24  assert.strictEqual(myUrl.search, '?foo=~bar');
25  myUrl.searchParams.sort();
26  assert.strictEqual(myUrl.search, '?foo=%7Ebar');
27}
28