Skip to content

Commit

Permalink
url: export URLSearchParams
Browse files Browse the repository at this point in the history
Fixes: #10761
  • Loading branch information
TimothyGu authored and targos committed Jan 22, 2017
1 parent 4f8582e commit 326e967
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 57 deletions.
1 change: 1 addition & 0 deletions lib/internal/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,7 @@ function urlToOptions(url) {
}

exports.URL = URL;
exports.URLSearchParams = URLSearchParams;
exports.originFor = originFor;
exports.domainToASCII = domainToASCII;
exports.domainToUnicode = domainToUnicode;
Expand Down
1 change: 1 addition & 0 deletions lib/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ exports.resolve = urlResolve;
exports.resolveObject = urlResolveObject;
exports.format = urlFormat;
exports.URL = internalUrl.URL;
exports.URLSearchParams = internalUrl.URLSearchParams;
exports.originFor = internalUrl.originFor;
exports.domainToASCII = internalUrl.domainToASCII;
exports.domainToUnicode = internalUrl.domainToUnicode;
Expand Down
8 changes: 2 additions & 6 deletions test/parallel/test-whatwg-url-searchparams-append.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

require('../common');
const assert = require('assert');
const URL = require('url').URL;
const URLSearchParams = require('url').URLSearchParams;

const m = new URL('http://example.org');
let params = m.searchParams;

// Until we export URLSearchParams
const URLSearchParams = params.constructor;
let params;

// Append same name
params = new URLSearchParams();
Expand Down
8 changes: 2 additions & 6 deletions test/parallel/test-whatwg-url-searchparams-constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

require('../common');
const assert = require('assert');
const URL = require('url').URL;
const URLSearchParams = require('url').URLSearchParams;

const m = new URL('http://example.org');
let params = m.searchParams;

// Until we export URLSearchParams
const URLSearchParams = params.constructor;
let params;

// Basic URLSearchParams construction
params = new URLSearchParams();
Expand Down
10 changes: 4 additions & 6 deletions test/parallel/test-whatwg-url-searchparams-delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

require('../common');
const assert = require('assert');
const URL = require('url').URL;
const url = require('url');
const URL = url.URL;
const URLSearchParams = url.URLSearchParams;

const m = new URL('http://example.org');
let params = m.searchParams;

// Until we export URLSearchParams
const URLSearchParams = params.constructor;
let params;

// Delete basics
params = new URLSearchParams('a=b&c=d');
Expand Down
12 changes: 4 additions & 8 deletions test/parallel/test-whatwg-url-searchparams-foreach.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@

require('../common');
const assert = require('assert');
const URL = require('url').URL;

const m = new URL('http://example.org');
let params = m.searchParams;

// Until we export URLSearchParams
const URLSearchParams = params.constructor;
const url = require('url');
const URL = url.URL;
const URLSearchParams = url.URLSearchParams;

let a, b, i;

// ForEach Check
params = new URLSearchParams('a=1&b=2&c=3');
const params = new URLSearchParams('a=1&b=2&c=3');
const keys = [];
const values = [];
params.forEach(function(value, key) {
Expand Down
8 changes: 2 additions & 6 deletions test/parallel/test-whatwg-url-searchparams-get.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

require('../common');
const assert = require('assert');
const URL = require('url').URL;
const URLSearchParams = require('url').URLSearchParams;

const m = new URL('http://example.org');
let params = m.searchParams;

// Until we export URLSearchParams
const URLSearchParams = params.constructor;
let params;

// Get basics
params = new URLSearchParams('a=b&c=d');
Expand Down
9 changes: 2 additions & 7 deletions test/parallel/test-whatwg-url-searchparams-getall.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@

require('../common');
const assert = require('assert');
const URL = require('url').URL;

const m = new URL('http://example.org');
let params = m.searchParams;

// Until we export URLSearchParams
const URLSearchParams = params.constructor;
const URLSearchParams = require('url').URLSearchParams;

let params;
let matches;

// getAll() basics
Expand Down
8 changes: 2 additions & 6 deletions test/parallel/test-whatwg-url-searchparams-has.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

require('../common');
const assert = require('assert');
const URL = require('url').URL;
const URLSearchParams = require('url').URLSearchParams;

const m = new URL('http://example.org');
let params = m.searchParams;

// Until we export URLSearchParams
const URLSearchParams = params.constructor;
let params;

// Has basics
params = new URLSearchParams('a=b&c=d');
Expand Down
8 changes: 2 additions & 6 deletions test/parallel/test-whatwg-url-searchparams-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

require('../common');
const assert = require('assert');
const URL = require('url').URL;
const URLSearchParams = require('url').URLSearchParams;

const m = new URL('http://example.org');
let params = m.searchParams;

// Until we export URLSearchParams
const URLSearchParams = params.constructor;
let params;

// Set basics
params = new URLSearchParams('a=b&c=d');
Expand Down
8 changes: 2 additions & 6 deletions test/parallel/test-whatwg-url-searchparams-stringifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

require('../common');
const assert = require('assert');
const URL = require('url').URL;
const URLSearchParams = require('url').URLSearchParams;

const m = new URL('http://example.org');
let params = m.searchParams;

// Until we export URLSearchParams
const URLSearchParams = params.constructor;
let params;

// Serialize space
// querystring does not currently handle spaces intelligently
Expand Down

1 comment on commit 326e967

@targos
Copy link
Member

@targos targos commented on 326e967 Jan 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR-URL: #10801
Fixes: #10761
Reviewed-By: Joyee Cheung joyeec9h3@gmail.com
Reviewed-By: James M Snell jasnell@gmail.com
Reviewed-By: Michaël Zasso targos@protonmail.com

Please sign in to comment.