| { |
| "importMapBaseURL": "https://base.example/path1/path2/path3", |
| "tests": { |
| "Relative URL specifier keys should absolutize strings prefixed with ./, ../, or / into the corresponding URLs": { |
| "importMap": { |
| "imports": { |
| "./foo": "/dotslash", |
| "../foo": "/dotdotslash", |
| "/foo": "/slash" |
| } |
| }, |
| "expectedParsedImportMap": { |
| "imports": { |
| "https://base.example/path1/path2/foo": "https://base.example/dotslash", |
| "https://base.example/path1/foo": "https://base.example/dotdotslash", |
| "https://base.example/foo": "https://base.example/slash" |
| }, |
| "scopes": {} |
| } |
| }, |
| "Relative URL specifier keys should not absolutize strings prefixed with ./, ../, or / with a data: URL base": { |
| "importMap": { |
| "imports": { |
| "./foo": "https://example.com/dotslash", |
| "../foo": "https://example.com/dotdotslash", |
| "/foo": "https://example.com/slash" |
| } |
| }, |
| "importMapBaseURL": "data:text/html,", |
| "expectedParsedImportMap": { |
| "imports": { |
| "./foo": "https://example.com/dotslash", |
| "../foo": "https://example.com/dotdotslash", |
| "/foo": "https://example.com/slash" |
| }, |
| "scopes": {} |
| } |
| }, |
| "Relative URL specifier keys should absolutize the literal strings ./, ../, or / with no suffix": { |
| "importMap": { |
| "imports": { |
| "./": "/dotslash/", |
| "../": "/dotdotslash/", |
| "/": "/slash/" |
| } |
| }, |
| "expectedParsedImportMap": { |
| "imports": { |
| "https://base.example/path1/path2/": "https://base.example/dotslash/", |
| "https://base.example/path1/": "https://base.example/dotdotslash/", |
| "https://base.example/": "https://base.example/slash/" |
| }, |
| "scopes": {} |
| } |
| }, |
| "Relative URL specifier keys should work with /s, ?s, and #s": { |
| "importMap": { |
| "imports": { |
| "./foo/bar?baz#qux": "/foo" |
| } |
| }, |
| "expectedParsedImportMap": { |
| "imports": { |
| "https://base.example/path1/path2/foo/bar?baz#qux": "https://base.example/foo" |
| }, |
| "scopes": {} |
| } |
| }, |
| "Relative URL specifier keys should ignore an empty string key": { |
| "importMap": { |
| "imports": { |
| "": "/foo" |
| } |
| }, |
| "expectedParsedImportMap": { |
| "imports": {}, |
| "scopes": {} |
| } |
| }, |
| "Relative URL specifier keys should treat percent-encoded variants of ./, ../, or / as bare specifiers": { |
| "importMap": { |
| "imports": { |
| "%2E/": "/dotSlash1/", |
| "%2E%2E/": "/dotDotSlash1/", |
| ".%2F": "/dotSlash2", |
| "..%2F": "/dotDotSlash2", |
| "%2F": "/slash2", |
| "%2E%2F": "/dotSlash3", |
| "%2E%2E%2F": "/dotDotSlash3" |
| } |
| }, |
| "expectedParsedImportMap": { |
| "imports": { |
| "%2E/": "https://base.example/dotSlash1/", |
| "%2E%2E/": "https://base.example/dotDotSlash1/", |
| ".%2F": "https://base.example/dotSlash2", |
| "..%2F": "https://base.example/dotDotSlash2", |
| "%2F": "https://base.example/slash2", |
| "%2E%2F": "https://base.example/dotSlash3", |
| "%2E%2E%2F": "https://base.example/dotDotSlash3" |
| }, |
| "scopes": {} |
| } |
| }, |
| "Relative URL specifier keys should deduplicate based on URL parsing rules": { |
| "importMap": { |
| "imports": { |
| "./foo/\\": "/foo1", |
| "./foo//": "/foo2", |
| "./foo\\\\": "/foo3" |
| } |
| }, |
| "expectedParsedImportMap": { |
| "imports": { |
| "https://base.example/path1/path2/foo//": "https://base.example/foo3" |
| }, |
| "scopes": {} |
| } |
| }, |
| "Absolute URL specifier keys should accept all absolute URL specifier keys, with or without fetch schemes": { |
| "importMap": { |
| "imports": { |
| "about:good": "/about", |
| "blob:good": "/blob", |
| "data:good": "/data", |
| "file:///good": "/file", |
| "filesystem:http://example.com/good/": "/filesystem/", |
| "http://good/": "/http/", |
| "https://good/": "/https/", |
| "ftp://good/": "/ftp/", |
| "import:bad": "/import", |
| "mailto:bad": "/mailto", |
| "javascript:bad": "/javascript", |
| "wss:bad": "/wss" |
| } |
| }, |
| "expectedParsedImportMap": { |
| "imports": { |
| "about:good": "https://base.example/about", |
| "blob:good": "https://base.example/blob", |
| "data:good": "https://base.example/data", |
| "file:///good": "https://base.example/file", |
| "filesystem:http://example.com/good/": "https://base.example/filesystem/", |
| "http://good/": "https://base.example/http/", |
| "https://good/": "https://base.example/https/", |
| "ftp://good/": "https://base.example/ftp/", |
| "import:bad": "https://base.example/import", |
| "mailto:bad": "https://base.example/mailto", |
| "javascript:bad": "https://base.example/javascript", |
| "wss://bad/": "https://base.example/wss" |
| }, |
| "scopes": {} |
| } |
| }, |
| "Absolute URL specifier keys should parse absolute URLs, treating unparseable ones as bare specifiers": { |
| "importMap": { |
| "imports": { |
| "https://example.com:demo": "/unparseable2", |
| "http://[www.example.com]/": "/unparseable3/", |
| "https:example.org": "/invalidButParseable1/", |
| "https://///example.com///": "/invalidButParseable2/", |
| "https://example.net": "/prettyNormal/", |
| "https://ex%41mple.com/": "/percentDecoding/" |
| } |
| }, |
| "expectedParsedImportMap": { |
| "imports": { |
| "https://example.com:demo": "https://base.example/unparseable2", |
| "http://[www.example.com]/": "https://base.example/unparseable3/", |
| "https://example.org/": "https://base.example/invalidButParseable1/", |
| "https://example.com///": "https://base.example/invalidButParseable2/", |
| "https://example.net/": "https://base.example/prettyNormal/", |
| "https://example.com/": "https://base.example/percentDecoding/" |
| }, |
| "scopes": {} |
| } |
| }, |
| "Specifier keys should be sort correctly (issue #181) - Test #1": { |
| "importMap": { |
| "imports": { |
| "https://example.com/aaa": "https://example.com/aaa", |
| "https://example.com/a": "https://example.com/a" |
| } |
| }, |
| "expectedParsedImportMap": { |
| "imports": { |
| "https://example.com/aaa": "https://example.com/aaa", |
| "https://example.com/a": "https://example.com/a" |
| }, |
| "scopes": {} |
| } |
| }, |
| "Specifier keys should be sort correctly (issue #181) - Test #2": { |
| "importMap": { |
| "imports": { |
| "https://example.com/a": "https://example.com/a", |
| "https://example.com/aaa": "https://example.com/aaa" |
| } |
| }, |
| "expectedParsedImportMap": { |
| "imports": { |
| "https://example.com/aaa": "https://example.com/aaa", |
| "https://example.com/a": "https://example.com/a" |
| }, |
| "scopes": {} |
| } |
| } |
| } |
| } |