welsonjs/node_modules/modernizr/feature-detects/url/parser.js

29 lines
663 B
JavaScript

/*!
{
"name": "URL parser",
"property": "urlparser",
"notes": [{
"name": "WHATWG Spec",
"href": "https://url.spec.whatwg.org/"
}],
"polyfills": ["urlparser"],
"authors": ["Ron Waldon (@jokeyrhyme)"],
"tags": ["url"]
}
!*/
/* DOC
Check if browser implements the URL constructor for parsing URLs.
*/
define(['Modernizr'], function(Modernizr) {
Modernizr.addTest('urlparser', function() {
var url;
try {
// have to actually try use it, because Safari defines a dud constructor
url = new URL('http://modernizr.com/');
return url.href === 'http://modernizr.com/';
} catch (e) {
return false;
}
});
});