forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
url: allow use of URL with http.request and https.request
PR-URL: nodejs#10638 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: Michal Zasso <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
- Loading branch information
1 parent
fac607c
commit 9c30bf1
Showing
6 changed files
with
61 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
// Flags: --expose-internals | ||
'use strict'; | ||
|
||
require('../common'); | ||
|
||
const URL = require('url').URL; | ||
const assert = require('assert'); | ||
const urlToOptions = require('internal/url').urlToOptions; | ||
|
||
const url = new URL('http://user:[email protected]:21/aaa/zzz?l=24#test'); | ||
const oldParams = url.searchParams; // for test of [SameObject] | ||
|
@@ -125,3 +127,18 @@ assert.strictEqual(url.toString(), | |
'https://user2:[email protected]:23/aaa/bbb?k=99#abcd'); | ||
assert.strictEqual((delete url.searchParams), true); | ||
assert.strictEqual(url.searchParams, oldParams); | ||
|
||
// Test urlToOptions | ||
{ | ||
const opts = | ||
urlToOptions(new URL('http://user:[email protected]:21/aaa/zzz?l=24#test')); | ||
assert.strictEqual(opts instanceof URL, false); | ||
assert.strictEqual(opts.protocol, 'http:'); | ||
assert.strictEqual(opts.auth, 'user:pass'); | ||
assert.strictEqual(opts.hostname, 'foo.bar.com'); | ||
assert.strictEqual(opts.port, 21); | ||
assert.strictEqual(opts.path, '/aaa/zzz?l=24'); | ||
assert.strictEqual(opts.pathname, '/aaa/zzz'); | ||
assert.strictEqual(opts.search, '?l=24'); | ||
assert.strictEqual(opts.hash, '#test'); | ||
} |