1234567891011121314151617181920212223 |
- 'use strict';
- 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 USE_NATIVE_URL = require('../internals/url-constructor-detection');
-
- var URL = getBuiltIn('URL');
-
- // `URL.parse` method
- // https://url.spec.whatwg.org/#dom-url-canparse
- $({ target: 'URL', stat: true, forced: !USE_NATIVE_URL }, {
- parse: function parse(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 null;
- }
- }
- });
|