polyfills.URL.meta.json Maven / Gradle / Ivy
The newest version!
{"aliases":["modernizr:urlparser","blissfuljs","default-3.4","default-3.5","default-3.6","default"],"browsers":{"chrome":"<49","firefox":"<29","ie":"9 - *","ie_mob":"*","safari":"*","firefox_mob":"<29","opera":"<36","android":"*","samsung_mob":"<5","ios_saf":"*"},"dependencies":["Object.defineProperties","Array.prototype.forEach"],"notes":["`searchParams` is not iterable and has no `forEach()`, `entries()`, `keys()`, `values()` methods","Polyfill requires Object getters so fails in IE < 8"],"license":"CC0","repo":"https://github.com/inexorabletash/polyfill","docs":"https://developer.mozilla.org/en-US/docs/Web/API/URL","install":{"module":"js-polyfills","paths":["url.js"]},"detectSource":"(function (global) {\n\t/*\n\t * Browsers may have:\n\t * No global URL object\n\t * URL with static methods only - may have a dummy constructor\n\t * URL with members except searchParams\n\t * Full URL API support\n\t */\n\t'use strict';\n\n\ttry {\n\t\tvar nativeURL = new global.URL('http://example.com');\n\n\t\treturn 'href' in nativeURL && 'searchParams' in nativeURL;\n\t}\n\tcatch (error) {\n\t\treturn false;\n\t}\n}(this))","testSource":"","baseDir":"URL","hasTests":true,"testsSource":"/* eslint-env mocha, browser*/\n/* global proclaim, it */\n\nfunction toArray(it) {\n\tvar a = [];\n\tfor (var cur = it.next(); !cur.done; cur = it.next()) {\n\t\ta.push(cur.value);\n\t}\n\treturn a;\n}\n\n\nit('URL IDL', function () {\n\tvar url = new URL('http://example.com:8080/foo/bar?a=1&b=2#p1');\n\tproclaim.equal(typeof url.protocol, 'string', 'protocol');\n\tproclaim.equal(typeof url.host, 'string', 'host');\n\tproclaim.equal(typeof url.hostname, 'string', 'hostname');\n\tproclaim.equal(typeof url.port, 'string', 'port');\n\tproclaim.equal(typeof url.pathname, 'string', 'pathname');\n\tproclaim.equal(typeof url.search, 'string', 'search');\n\tproclaim.equal(typeof url.hash, 'string', 'hash');\n\tproclaim.equal(typeof url.origin, 'string', 'origin');\n\tproclaim.equal(typeof url.href, 'string', 'href');\n});\n\nit('URL Stringifying', function() {\n\tproclaim.equal(String(new URL('http://example.com')), 'http://example.com/');\n\tproclaim.equal(String(new URL('http://example.com:8080')), 'http://example.com:8080/');\n});\n\nit('URL Parsing', function () {\n\tvar url = new URL('http://example.com:8080/foo/bar?a=1&b=2#p1');\n\tproclaim.equal(url.protocol, 'http:');\n\tproclaim.equal(url.hostname, 'example.com');\n\tproclaim.equal(url.port, '8080');\n\tproclaim.equal(url.host, 'example.com:8080');\n\tproclaim.equal(url.pathname, '/foo/bar');\n\tproclaim.equal(url.search, '?a=1&b=2');\n\tproclaim.equal(url.hash, '#p1');\n\tproclaim.equal(url.origin, 'http://example.com:8080');\n\tproclaim.equal(url.href, 'http://example.com:8080/foo/bar?a=1&b=2#p1');\n});\n\nit('URL Mutation', function () {\n\tvar url = new URL('http://example.com');\n\tproclaim.equal(url.href, 'http://example.com/');\n\tproclaim.equal(url.origin, 'http://example.com');\n\tproclaim.equal(url.host, 'example.com');\n\n\turl.protocol = 'ftp';\n\tproclaim.equal(url.protocol, 'ftp:');\n\tproclaim.equal(url.href, 'ftp://example.com/');\n\n\t// Fails in native IE13 (Edge)\n\t// Probable bug in IE. https://twitter.com/patrickkettner/status/768726160070934529\n\t//proclaim.equal(url.origin, 'ftp://example.com');\n\n\tproclaim.equal(url.host, 'example.com');\n\turl.protocol = 'http';\n\tproclaim.equal(url.protocol, 'http:');\n\tproclaim.equal(url.href, 'http://example.com/');\n\tproclaim.equal(url.origin, 'http://example.com');\n\tproclaim.equal(url.host, 'example.com');\n\n\turl = new URL('http://example.com');\n\turl.hostname = 'example.org';\n\tproclaim.equal(url.href, 'http://example.org/');\n\tproclaim.equal(url.origin, 'http://example.org');\n\tproclaim.equal(url.host, 'example.org');\n\turl.hostname = 'example.com';\n\tproclaim.equal(url.href, 'http://example.com/');\n\tproclaim.equal(url.origin, 'http://example.com');\n\tproclaim.equal(url.host, 'example.com');\n\n\turl = new URL('http://example.com');\n\turl.port = 8080;\n\tproclaim.equal(url.href, 'http://example.com:8080/');\n\tproclaim.equal(url.origin, 'http://example.com:8080');\n\tproclaim.equal(url.host, 'example.com:8080');\n\turl.port = 80;\n\tproclaim.equal(url.href, 'http://example.com/');\n\tproclaim.equal(url.origin, 'http://example.com');\n\tproclaim.equal(url.host, 'example.com');\n\n\turl = new URL('http://example.com');\n\turl.pathname = 'foo';\n\tproclaim.equal(url.href, 'http://example.com/foo');\n\tproclaim.equal(url.origin, 'http://example.com');\n\turl.pathname = 'foo/bar';\n\tproclaim.equal(url.href, 'http://example.com/foo/bar');\n\tproclaim.equal(url.origin, 'http://example.com');\n\turl.pathname = '';\n\tproclaim.equal(url.href, 'http://example.com/');\n\tproclaim.equal(url.origin, 'http://example.com');\n\n\turl = new URL('http://example.com');\n\turl.search = 'a=1&b=2';\n\tproclaim.equal(url.href, 'http://example.com/?a=1&b=2');\n\tproclaim.equal(url.origin, 'http://example.com');\n\turl.search = '';\n\tproclaim.equal(url.href, 'http://example.com/');\n\tproclaim.equal(url.origin, 'http://example.com');\n\n\turl = new URL('http://example.com');\n\turl.hash = 'p1';\n\tproclaim.equal(url.href, 'http://example.com/#p1');\n\tproclaim.equal(url.origin, 'http://example.com');\n\turl.hash = '';\n\tproclaim.equal(url.href, 'http://example.com/');\n\tproclaim.equal(url.origin, 'http://example.com');\n});\n\nit('Parameter Mutation', function () {\n\tvar url = new URL('http://example.com');\n\tproclaim.equal(url.href, 'http://example.com/');\n\tproclaim.equal(url.search, '');\n\tproclaim.equal(url.searchParams.get('a'), null);\n\tproclaim.equal(url.searchParams.get('b'), null);\n\n\turl.searchParams.append('a', '1');\n\tproclaim.equal(url.searchParams.get('a'), '1');\n\tproclaim.deepEqual(url.searchParams.getAll('a'), ['1']);\n\tproclaim.equal(url.search, '?a=1');\n\tproclaim.equal(url.href, 'http://example.com/?a=1');\n\n\turl.searchParams.append('b', '2');\n\tproclaim.equal(url.searchParams.get('b'), '2');\n\tproclaim.deepEqual(url.searchParams.getAll('b'), ['2']);\n\tproclaim.equal(url.search, '?a=1&b=2');\n\tproclaim.equal(url.href, 'http://example.com/?a=1&b=2');\n\n\turl.searchParams.append('a', '3');\n\tproclaim.equal(url.searchParams.get('a'), '1');\n\tproclaim.deepEqual(url.searchParams.getAll('a'), ['1', '3']);\n\tproclaim.equal(url.search, '?a=1&b=2&a=3');\n\tproclaim.equal(url.href, 'http://example.com/?a=1&b=2&a=3');\n\n\turl.searchParams['delete']('a');\n\tproclaim.equal(url.search, '?b=2');\n\tproclaim.deepEqual(url.searchParams.getAll('a'), []);\n\tproclaim.equal(url.href, 'http://example.com/?b=2');\n\n\turl.searchParams['delete']('b');\n\tproclaim.deepEqual(url.searchParams.getAll('b'), []);\n\tproclaim.equal(url.href, 'http://example.com/');\n\n\turl.href = 'http://example.com?m=9&n=3';\n\tproclaim.equal(url.searchParams.has('a'), false);\n\tproclaim.equal(url.searchParams.has('b'), false);\n\tproclaim.equal(url.searchParams.get('m'), 9);\n\tproclaim.equal(url.searchParams.get('n'), 3);\n\n\turl.href = 'http://example.com';\n\turl.searchParams.set('a', '1');\n\tproclaim.deepEqual(url.searchParams.getAll('a'), ['1']);\n\turl.search = 'a=1&b=1&b=2&c=1';\n\turl.searchParams.set('b', '3');\n\tproclaim.deepEqual(url.searchParams.getAll('b'), ['3']);\n\tproclaim.equal(url.href, 'http://example.com/?a=1&b=3&c=1');\n});\n\nit('Parameter Encoding', function () {\n\tvar url = new URL('http://example.com');\n\tproclaim.equal(url.href, 'http://example.com/');\n\tproclaim.equal(url.search, '');\n\turl.searchParams.append('this\\x00&that\\x7f\\xff', '1+2=3');\n\tproclaim.equal(url.searchParams.get('this\\x00&that\\x7f\\xff'), '1+2=3');\n\n\t// The following fail in FF (tested in 38) against native impl\n\t//proclaim.equal(url.search, '?this%00%26that%7F%C3%BF=1%2B2%3D3');\n\t//proclaim.equal(url.href, 'http://example.com/?this%00%26that%7F%C3%BF=1%2B2%3D3');\n\n\turl.search = '';\n\turl.searchParams.append('a b', 'a b');\n\tproclaim.equal(url.search, '?a++b=a++b');\n\tproclaim.equal(url.searchParams.get('a b'), 'a b');\n});\n\n\nit('Base URL', function () {\n\t// fully qualified URL\n\tproclaim.equal(new URL('http://example.com', 'https://example.org').href, 'http://example.com/');\n\tproclaim.equal(new URL('http://example.com/foo/bar', 'https://example.org').href, 'http://example.com/foo/bar');\n\n\t// protocol relative\n\tproclaim.equal(new URL('//example.com', 'https://example.org').href, 'https://example.com/');\n\n\t// path relative\n\tproclaim.equal(new URL('/foo/bar', 'https://example.org').href, 'https://example.org/foo/bar');\n\tproclaim.equal(new URL('/foo/bar', 'https://example.org/baz/bat').href, 'https://example.org/foo/bar');\n\tproclaim.equal(new URL('./bar', 'https://example.org').href, 'https://example.org/bar');\n\tproclaim.equal(new URL('./bar', 'https://example.org/foo/').href, 'https://example.org/foo/bar');\n\tproclaim.equal(new URL('bar', 'https://example.org/foo/').href, 'https://example.org/foo/bar');\n\tproclaim.equal(new URL('../bar', 'https://example.org/foo/').href, 'https://example.org/bar');\n\tproclaim.equal(new URL('../bar', 'https://example.org/foo/').href, 'https://example.org/bar');\n\tproclaim.equal(new URL('../../bar', 'https://example.org/foo/baz/bat/').href, 'https://example.org/foo/bar');\n\tproclaim.equal(new URL('../../bar', 'https://example.org/foo/baz/bat').href, 'https://example.org/bar');\n\tproclaim.equal(new URL('../../bar', 'https://example.org/foo/baz/').href, 'https://example.org/bar');\n\tproclaim.equal(new URL('../../bar', 'https://example.org/foo/').href, 'https://example.org/bar');\n\tproclaim.equal(new URL('../../bar', 'https://example.org/foo/').href, 'https://example.org/bar');\n\n\t// search/hash relative\n\tproclaim.equal(new URL('bar?ab#cd', 'https://example.org/foo/').href, 'https://example.org/foo/bar?ab#cd');\n\tproclaim.equal(new URL('bar?ab#cd', 'https://example.org/foo').href, 'https://example.org/bar?ab#cd');\n\tproclaim.equal(new URL('?ab#cd', 'https://example.org/foo').href, 'https://example.org/foo?ab#cd');\n\tproclaim.equal(new URL('?ab', 'https://example.org/foo').href, 'https://example.org/foo?ab');\n\tproclaim.equal(new URL('#cd', 'https://example.org/foo').href, 'https://example.org/foo#cd');\n});\n\nit('URLSearchParams', function () {\n\tvar url = new URL('http://example.com?a=1&b=2');\n\tproclaim.ok(url.searchParams instanceof URLSearchParams);\n\n\tproclaim.equal(String(new URLSearchParams()), '');\n\tproclaim.equal(String(new URLSearchParams('')), '');\n\tproclaim.equal(String(new URLSearchParams('a=1')), 'a=1');\n\tproclaim.equal(String(new URLSearchParams('a=1&b=1')), 'a=1&b=1');\n\tproclaim.equal(String(new URLSearchParams('a=1&b&a')), 'a=1&b=&a=');\n\n\t// The following fail in FF (tested in 38) against native impl\n\t// but FF38 passes the detect\n\t/*\n\tproclaim.equal(String(new URLSearchParams('?')), '');\n\tproclaim.equal(String(new URLSearchParams('?a=1')), 'a=1');\n\tproclaim.equal(String(new URLSearchParams('?a=1&b=1')), 'a=1&b=1');\n\tproclaim.equal(String(new URLSearchParams('?a=1&b&a')), 'a=1&b=&a=');\n\n\tproclaim.equal(String(new URLSearchParams(new URLSearchParams('?'))), '');\n\tproclaim.equal(String(new URLSearchParams(new URLSearchParams('?a=1'))), 'a=1');\n\tproclaim.equal(String(new URLSearchParams(new URLSearchParams('?a=1&b=1'))), 'a=1&b=1');\n\tproclaim.equal(String(new URLSearchParams(new URLSearchParams('?a=1&b&a'))), 'a=1&b=&a=');\n\t*/\n});\n\nit('URLSearchParams mutation', function () {\n\tvar p = new URLSearchParams();\n\tproclaim.equal(p.get('a'), null);\n\tproclaim.equal(p.get('b'), null);\n\n\tp.append('a', '1');\n\tproclaim.equal(p.get('a'), '1');\n\tproclaim.deepEqual(p.getAll('a'), ['1']);\n\tproclaim.equal(String(p), 'a=1');\n\n\tp.append('b', '2');\n\tproclaim.equal(p.get('b'), '2');\n\tproclaim.deepEqual(p.getAll('b'), ['2']);\n\tproclaim.equal(String(p), 'a=1&b=2');\n\n\tp.append('a', '3');\n\tproclaim.equal(p.get('a'), '1');\n\tproclaim.deepEqual(p.getAll('a'), ['1', '3']);\n\tproclaim.equal(String(p), 'a=1&b=2&a=3');\n\n\tp['delete']('a');\n\tproclaim.equal(String(p), 'b=2');\n\tproclaim.deepEqual(p.getAll('a'), []);\n\n\tp['delete']('b');\n\tproclaim.deepEqual(p.getAll('b'), []);\n\n\tp = new URLSearchParams('m=9&n=3');\n\tproclaim.equal(p.has('a'), false);\n\tproclaim.equal(p.has('b'), false);\n\tproclaim.equal(p.get('m'), 9);\n\tproclaim.equal(p.get('n'), 3);\n\n\tp = new URLSearchParams();\n\tp.set('a', '1');\n\tproclaim.deepEqual(p.getAll('a'), ['1']);\n\tp = new URLSearchParams('a=1&b=1&b=2&c=1');\n\tp.set('b', '3');\n\tproclaim.deepEqual(p.getAll('b'), ['3']);\n\tproclaim.equal(String(p), 'a=1&b=3&c=1');\n\n\t// Ensure copy constructor copies by value, not reference.\n\tvar sp1 = new URLSearchParams('a=1');\n\tproclaim.equal(String(sp1), 'a=1');\n\tvar sp2 = new URLSearchParams(sp1);\n\tproclaim.equal(String(sp2), 'a=1');\n\tsp1.append('b', '2');\n\tsp2.append('c', '3');\n\tproclaim.equal(String(sp1), 'a=1&b=2');\n\tproclaim.equal(String(sp2), 'a=1&c=3');\n});\n\n// The following fail in FF (tested in 38) against native impl\n// but FF38 passes the detect\n/*\nit('URLSearchParams serialization', function() {\n\tvar p = new URLSearchParams();\n\tp.append('this\\x00&that\\x7f\\xff', '1+2=3');\n\tproclaim.equal(p.get('this\\x00&that\\x7f\\xff'), '1+2=3');\n\tproclaim.equal(String(p), 'this%00%26that%7F%C3%BF=1%2B2%3D3');\n\tp = new URLSearchParams();\n\tp.append('a b', 'a b');\n\tproclaim.equal(String(p), 'a++b=a++b');\n\tproclaim.equal(p.get('a b'), 'a b');\n});\n\nit('URLSearchParams iterable methods', function () {\n\tvar params = new URLSearchParams('a=1&b=2');\n\tproclaim.deepEqual(toArray(params.entries()), [['a', '1'], ['b', '2']]);\n\tproclaim.deepEqual(toArray(params.keys()), ['a', 'b']);\n\tproclaim.deepEqual(toArray(params.values()), ['1', '2']);\n\n\tif ('Symbol' in self && 'iterator' in self.Symbol) {\n\t\tproclaim.deepEqual(toArray(params[Symbol.iterator]()), [['a', '1'], ['b', '2']]);\n\t}\n});\n*/\n\n// Not implemented by the polyfill!\n/*\nit('URL contains native static methods', function () {\n\t\tproclaim.ok(typeof URL.createObjectURL == 'function');\n\t\tproclaim.ok(typeof URL.revokeObjectURL == 'function');\n});\n*/\n\nit('Regression tests', function() {\n\t// IE mangles the pathname when assigning to search with 'about:' URLs\n\tvar p = new URL('about:blank').searchParams;\n\tp.append('a', 1);\n\tp.append('b', 2);\n\tproclaim.equal(p.toString(), 'a=1&b=2');\n});"}