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 italoacasas committed Jan 30, 2017
1 parent c4f1694 commit 021338d
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 @@ -1022,6 +1022,7 @@ function domainToUnicode(domain) {
}

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

2 comments on commit 021338d

@MylesBorins
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing PR-URL 😢

@jasnell
Copy link
Member

@jasnell jasnell commented on 021338d Mar 8, 2017

Choose a reason for hiding this comment

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

Yeah, there appear to be a handful of backport commits landed for 7.7.0 that were pushed without the necessary metadata. I've made a note in a separate commit letting @italoacasas know.

Please sign in to comment.