-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
101 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
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 |
---|---|---|
|
@@ -199,4 +199,7 @@ export default { | |
3.29: [ | ||
'web.url-search-params.size', | ||
], | ||
'3.30': [ | ||
'web.url.can-parse', | ||
], | ||
}; |
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,3 @@ | ||
var parent = require('../../stable/url/can-parse'); | ||
|
||
module.exports = parent; |
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,3 @@ | ||
var parent = require('../../actual/url/can-parse'); | ||
|
||
module.exports = parent; |
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,21 @@ | ||
var $ = require('../internals/export'); | ||
var getBuiltIn = require('../internals/get-built-in'); | ||
var validateArgumentsLength = require('../internals/validate-arguments-length'); | ||
var toString = require('../internals/to-string'); | ||
|
||
var URL = getBuiltIn('URL'); | ||
|
||
// `URL.canParse` method | ||
// https://url.spec.whatwg.org/#dom-url-canparse | ||
$({ target: 'URL', stat: true }, { | ||
canParse: function canParse(url) { | ||
var length = validateArgumentsLength(arguments.length, 1); | ||
var urlString = toString(url); | ||
var base = length < 2 || arguments[1] === undefined ? undefined : toString(arguments[1]); | ||
try { | ||
return !!new URL(urlString, base); | ||
} catch (error) { | ||
return false; | ||
} | ||
} | ||
}); |
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,5 +1,6 @@ | ||
// https://github.com/jasnell/proposal-url | ||
require('../modules/web.url'); | ||
require('../modules/web.url.can-parse'); | ||
require('../modules/web.url.to-json'); | ||
require('../modules/web.url-search-params'); | ||
require('../modules/web.url-search-params.size'); |
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,5 @@ | ||
require('../../modules/web.url'); | ||
require('../../modules/web.url.can-parse'); | ||
var path = require('../../internals/path'); | ||
|
||
module.exports = path.URL.canParse; |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
QUnit.test('URL.canParse', assert => { | ||
const { canParse } = URL; | ||
|
||
assert.isFunction(canParse); | ||
assert.arity(canParse, 1); | ||
assert.name(canParse, 'canParse'); | ||
assert.looksNative(canParse); | ||
|
||
assert.false(canParse(undefined), 'undefined'); | ||
assert.false(canParse(undefined, undefined), 'undefined, undefined'); | ||
assert.true(canParse('q:w'), 'q:w'); | ||
assert.true(canParse('q:w', undefined), 'q:w, undefined'); | ||
assert.false(canParse(undefined, 'q:w'), 'undefined, q:w'); | ||
assert.true(canParse('q:/w'), 'q:/w'); | ||
assert.true(canParse('q:/w', undefined), 'q:w, undefined'); | ||
assert.true(canParse(undefined, 'q:/w'), 'undefined, q:w'); | ||
assert.false(canParse('https://login:password@examp:le.com:8080/?a=1&b=2&a=3&c=4#fragment'), 'https://login:password@examp:le.com:8080/?a=1&b=2&a=3&c=4#fragment'); | ||
assert.true(canParse('https://login:password@example.com:8080/?a=1&b=2&a=3&c=4#fragment'), 'https://login:password@example.com:8080/?a=1&b=2&a=3&c=4#fragment'); | ||
assert.true(canParse('https://login:password@example.com:8080/?a=1&b=2&a=3&c=4#fragment', undefined), 'https://login:password@example.com:8080/?a=1&b=2&a=3&c=4#fragment, undefined'); | ||
assert.true(canParse('x', 'https://login:password@example.com:8080/?a=1&b=2&a=3&c=4#fragment'), 'x, https://login:password@example.com:8080/?a=1&b=2&a=3&c=4#fragment'); | ||
|
||
assert.throws(() => canParse(), 'no args'); | ||
assert.throws(() => canParse({ toString() { throw Error('thrower'); } }), 'conversion thrower #1'); | ||
assert.throws(() => canParse('q:w', { toString() { throw Error('thrower'); } }), 'conversion thrower #2'); | ||
}); |
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,24 @@ | ||
import canParse from 'core-js-pure/stable/url/can-parse'; | ||
|
||
QUnit.test('URL.canParse', assert => { | ||
assert.isFunction(canParse); | ||
assert.arity(canParse, 1); | ||
assert.name(canParse, 'canParse'); | ||
|
||
assert.false(canParse(undefined), 'undefined'); | ||
assert.false(canParse(undefined, undefined), 'undefined, undefined'); | ||
assert.true(canParse('q:w'), 'q:w'); | ||
assert.true(canParse('q:w', undefined), 'q:w, undefined'); | ||
assert.false(canParse(undefined, 'q:w'), 'undefined, q:w'); | ||
assert.true(canParse('q:/w'), 'q:/w'); | ||
assert.true(canParse('q:/w', undefined), 'q:w, undefined'); | ||
assert.true(canParse(undefined, 'q:/w'), 'undefined, q:w'); | ||
assert.false(canParse('https://login:password@examp:le.com:8080/?a=1&b=2&a=3&c=4#fragment'), 'https://login:password@examp:le.com:8080/?a=1&b=2&a=3&c=4#fragment'); | ||
assert.true(canParse('https://login:password@example.com:8080/?a=1&b=2&a=3&c=4#fragment'), 'https://login:password@example.com:8080/?a=1&b=2&a=3&c=4#fragment'); | ||
assert.true(canParse('https://login:password@example.com:8080/?a=1&b=2&a=3&c=4#fragment', undefined), 'https://login:password@example.com:8080/?a=1&b=2&a=3&c=4#fragment, undefined'); | ||
assert.true(canParse('x', 'https://login:password@example.com:8080/?a=1&b=2&a=3&c=4#fragment'), 'x, https://login:password@example.com:8080/?a=1&b=2&a=3&c=4#fragment'); | ||
|
||
assert.throws(() => canParse(), 'no args'); | ||
assert.throws(() => canParse({ toString() { throw Error('thrower'); } }), 'conversion thrower #1'); | ||
assert.throws(() => canParse('q:w', { toString() { throw Error('thrower'); } }), 'conversion thrower #2'); | ||
}); |