parser.js 663 B

12345678910111213141516171819202122232425262728
  1. /*!
  2. {
  3. "name": "URL parser",
  4. "property": "urlparser",
  5. "notes": [{
  6. "name": "WHATWG Spec",
  7. "href": "https://url.spec.whatwg.org/"
  8. }],
  9. "polyfills": ["urlparser"],
  10. "authors": ["Ron Waldon (@jokeyrhyme)"],
  11. "tags": ["url"]
  12. }
  13. !*/
  14. /* DOC
  15. Check if browser implements the URL constructor for parsing URLs.
  16. */
  17. define(['Modernizr'], function(Modernizr) {
  18. Modernizr.addTest('urlparser', function() {
  19. var url;
  20. try {
  21. // have to actually try use it, because Safari defines a dud constructor
  22. url = new URL('http://modernizr.com/');
  23. return url.href === 'http://modernizr.com/';
  24. } catch (e) {
  25. return false;
  26. }
  27. });
  28. });