UNPKG

modernizr

Version:

Modernizr is a JavaScript library that detects HTML5 and CSS3 features in the user’s browser.

29 lines (28 loc) 680 B
/*! { "name": "URL parser", "property": "urlparser", "notes": [{ "name": "URL", "href": "https://dvcs.w3.org/hg/url/raw-file/tip/Overview.html" }], "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; } }); });