diff --git a/reference-implementation/__tests__/parsing-scope-keys.js b/reference-implementation/__tests__/parsing-scope-keys.js index 6b50c2c..4993f3a 100644 --- a/reference-implementation/__tests__/parsing-scope-keys.js +++ b/reference-implementation/__tests__/parsing-scope-keys.js @@ -62,7 +62,7 @@ describe('Relative URL scope keys', () => { }); describe('Absolute URL scope keys', () => { - it('should only accept absolute URL scope keys with fetch schemes', () => { + it('should accept all absolute URL scope keys, with or without fetch schemes', () => { expectScopes( [ 'about:good', @@ -87,14 +87,13 @@ describe('Absolute URL scope keys', () => { 'filesystem:http://example.com/good/', 'http://good/', 'https://good/', - 'ftp://good/' + 'ftp://good/', + 'import:bad', + 'mailto:bad', + 'javascript:bad', + 'wss://ba/' ], - [ - 'Invalid scope "import:bad". Scope URLs must have a fetch scheme.', - 'Invalid scope "mailto:bad". Scope URLs must have a fetch scheme.', - 'Invalid scope "javascript:bad". Scope URLs must have a fetch scheme.', - 'Invalid scope "wss://ba/". Scope URLs must have a fetch scheme.' - ] + [] ); }); diff --git a/reference-implementation/lib/parser.js b/reference-implementation/lib/parser.js index 9e1a9ea..583a520 100644 --- a/reference-implementation/lib/parser.js +++ b/reference-implementation/lib/parser.js @@ -1,6 +1,6 @@ 'use strict'; const assert = require('assert'); -const { tryURLParse, hasFetchScheme, tryURLLikeSpecifierParse } = require('./utils.js'); +const { tryURLParse, tryURLLikeSpecifierParse } = require('./utils.js'); exports.parseFromString = (input, baseURL) => { const parsed = JSON.parse(input); @@ -92,11 +92,6 @@ function sortAndNormalizeScopes(obj, baseURL) { continue; } - if (!hasFetchScheme(scopePrefixURL)) { - console.warn(`Invalid scope "${scopePrefixURL}". Scope URLs must have a fetch scheme.`); - continue; - } - const normalizedScopePrefix = scopePrefixURL.href; normalized[normalizedScopePrefix] = sortAndNormalizeSpecifierMap(potentialSpecifierMap, baseURL); } diff --git a/reference-implementation/lib/utils.js b/reference-implementation/lib/utils.js index 1050d84..6f04e5c 100644 --- a/reference-implementation/lib/utils.js +++ b/reference-implementation/lib/utils.js @@ -1,9 +1,6 @@ 'use strict'; const { URL } = require('url'); -// https://fetch.spec.whatwg.org/#fetch-scheme -const FETCH_SCHEMES = new Set(['http', 'https', 'ftp', 'about', 'blob', 'data', 'file', 'filesystem']); - exports.tryURLParse = (string, baseURL) => { try { return new URL(string, baseURL); @@ -20,7 +17,3 @@ exports.tryURLLikeSpecifierParse = (specifier, baseURL) => { const url = exports.tryURLParse(specifier); return url; }; - -exports.hasFetchScheme = url => { - return FETCH_SCHEMES.has(url.protocol.slice(0, -1)); -}; diff --git a/spec.bs b/spec.bs index c973a35..4d47aa8 100644 --- a/spec.bs +++ b/spec.bs @@ -332,9 +332,6 @@ To register an import map given an {{HTMLScriptElement}} |element|: 1. If |scopePrefixURL| is failure, then: 1. [=Report a warning to the console=] that the scope prefix URL was not parseable. 1. [=Continue=]. - 1. If |scopePrefixURL|'s [=url/scheme=] is not a [=fetch scheme=], then: - 1. [=Report a warning to the console=] that scope prefix URLs must have a fetch scheme. - 1. [=Continue=]. 1. Let |normalizedScopePrefix| be the [=URL serializer|serialization=] of |scopePrefixURL|. 1. Set |normalized|[|normalizedScopePrefix|] to the result of [=sorting and normalizing a specifier map=] given |potentialSpecifierMap| and |baseURL|. 1. Return the result of [=map/sorting=] |normalized|, with an entry |a| being less than an entry |b| if |b|'s [=map/key=] is [=code unit less than=] |a|'s [=map/key=].