-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
url, test: including base argument in originFor
- Add tests to check if the `originFor` implementation for WHATWG url parsing is correnct. - Fix `originFor` by including a base as argument PR-URL: #10021 Reviewed-By: James M Snell <jasnell@gmail.com>
- Loading branch information
1 parent
1f11deb
commit 80cccce
Showing
2 changed files
with
21 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
|
||
const URL = require('url').URL; | ||
const path = require('path'); | ||
const assert = require('assert'); | ||
const tests = require(path.join(common.fixturesDir, 'url-tests.json')); | ||
|
||
for (const test of tests) { | ||
if (typeof test === 'string') | ||
continue; | ||
|
||
if (test.origin) { | ||
const origin = URL.originFor(test.input, test.base); | ||
// Pass true to origin.toString() to enable unicode serialization. | ||
assert.strictEqual(origin.toString(true), test.origin); | ||
} | ||
} |