diff --git a/reference-implementation/__tests__/json/url-specifiers-schemes.json b/reference-implementation/__tests__/json/url-specifiers-schemes.json new file mode 100644 index 0000000..58a9764 --- /dev/null +++ b/reference-implementation/__tests__/json/url-specifiers-schemes.json @@ -0,0 +1,45 @@ +{ + "importMap": { + "imports": { + "data:text/": "/lib/test-data/", + "about:text/": "/lib/test-about/", + "blob:text/": "/lib/test-blob/", + "blah:text/": "/lib/test-blah/", + "http:text/": "/lib/test-http/", + "https:text/": "/lib/test-https/", + "file:text/": "/lib/test-file/", + "ftp:text/": "/lib/test-ftp/", + "ws:text/": "/lib/test-ws/", + "wss:text/": "/lib/test-wss/" + } + }, + "importMapBaseURL": "https://example.com/app/index.html", + "baseURL": "https://example.com/js/app.mjs", + "name": "URL-like specifiers", + "tests": { + "Non-special vs. special schemes": { + "expectedResults": { + "data:text/javascript,console.log('foo')": "data:text/javascript,console.log('foo')", + "data:text/": "https://example.com/lib/test-data/", + "about:text/foo": "about:text/foo", + "about:text/": "https://example.com/lib/test-about/", + "blob:text/foo": "blob:text/foo", + "blob:text/": "https://example.com/lib/test-blob/", + "blah:text/foo": "blah:text/foo", + "blah:text/": "https://example.com/lib/test-blah/", + "http:text/foo": "https://example.com/lib/test-http/foo", + "http:text/": "https://example.com/lib/test-http/", + "https:text/foo": "https://example.com/lib/test-https/foo", + "https:text/": "https://example.com/lib/test-https/", + "ftp:text/foo": "https://example.com/lib/test-ftp/foo", + "ftp:text/": "https://example.com/lib/test-ftp/", + "file:text/foo": "https://example.com/lib/test-file/foo", + "file:text/": "https://example.com/lib/test-file/", + "ws:text/foo": "https://example.com/lib/test-ws/foo", + "ws:text/": "https://example.com/lib/test-ws/", + "wss:text/foo": "https://example.com/lib/test-wss/foo", + "wss:text/": "https://example.com/lib/test-wss/" + } + } + } +} diff --git a/reference-implementation/__tests__/json/url-specifiers.json b/reference-implementation/__tests__/json/url-specifiers.json index 8793b2c..aff55c4 100644 --- a/reference-implementation/__tests__/json/url-specifiers.json +++ b/reference-implementation/__tests__/json/url-specifiers.json @@ -9,14 +9,7 @@ "/test/": "/lib/url-trailing-slash/", "./test/": "/lib/url-trailing-slash-dot/", "/test": "/lib/test1.mjs", - "../test": "/lib/test2.mjs", - "data:text/": "/lib/test-data/", - "about:text/": "/lib/test-about/", - "blob:text/": "/lib/test-blob/", - "blah:text/": "/lib/test-blah/", - "file:text/": "/lib/test-file/", - "ftp:text/": "/lib/test-ftp/", - "ws:text/": "/lib/test-ws/" + "../test": "/lib/test2.mjs" } }, "importMapBaseURL": "https://example.com/app/index.html", @@ -54,24 +47,6 @@ "expectedResults": { "/test": "https://example.com/lib/test2.mjs" } - }, - "Non-special vs. special schemes": { - "expectedResults": { - "data:text/javascript,console.log('foo')": "data:text/javascript,console.log('foo')", - "data:text/": "https://example.com/lib/test-data/", - "about:text/foo": "about:text/foo", - "about:text/": "https://example.com/lib/test-about/", - "blob:text/foo": "blob:text/foo", - "blob:text/": "https://example.com/lib/test-blob/", - "blah:text/foo": "blah:text/foo", - "blah:text/": "https://example.com/lib/test-blah/", - "ftp:text/foo": "https://example.com/lib/test-ftp/foo", - "ftp:text/": "https://example.com/lib/test-ftp/", - "file:text/foo": "https://example.com/lib/test-file/foo", - "file:text/": "https://example.com/lib/test-file/", - "ws:text/foo": "https://example.com/lib/test-ws/foo", - "ws:text/": "https://example.com/lib/test-ws/" - } } } } diff --git a/reference-implementation/lib/utils.js b/reference-implementation/lib/utils.js index 515395c..e0d0bbd 100644 --- a/reference-implementation/lib/utils.js +++ b/reference-implementation/lib/utils.js @@ -19,5 +19,5 @@ exports.tryURLLikeSpecifierParse = (specifier, baseURL) => { }; // https://url.spec.whatwg.org/#special-scheme -const specialProtocols = new Set(["ftp:", "file:", "http:", "https:", "ws:", "wss:"]); +const specialProtocols = new Set(['ftp:', 'file:', 'http:', 'https:', 'ws:', 'wss:']); exports.isSpecial = url => specialProtocols.has(url.protocol);