url-specifiers.json (2999B)
1 { 2 "importMap": { 3 "imports": { 4 "/lib/foo.mjs": "./more/bar.mjs", 5 "./dotrelative/foo.mjs": "/lib/dot.mjs", 6 "../dotdotrelative/foo.mjs": "/lib/dotdot.mjs", 7 "/": "/lib/slash-only/", 8 "./": "/lib/dotslash-only/", 9 "/test/": "/lib/url-trailing-slash/", 10 "./test/": "/lib/url-trailing-slash-dot/", 11 "/test": "/lib/test1.mjs", 12 "../test": "/lib/test2.mjs" 13 } 14 }, 15 "importMapBaseURL": "https://example.com/app/index.html", 16 "baseURL": "https://example.com/js/app.mjs", 17 "name": "URL-like specifiers", 18 "tests": { 19 "Ordinary URL-like specifiers": { 20 "expectedResults": { 21 "https://example.com/lib/foo.mjs": "https://example.com/app/more/bar.mjs", 22 "https://///example.com/lib/foo.mjs": "https://example.com/app/more/bar.mjs", 23 "/lib/foo.mjs": "https://example.com/app/more/bar.mjs", 24 "https://example.com/app/dotrelative/foo.mjs": "https://example.com/lib/dot.mjs", 25 "../app/dotrelative/foo.mjs": "https://example.com/lib/dot.mjs", 26 "https://example.com/dotdotrelative/foo.mjs": "https://example.com/lib/dotdot.mjs", 27 "../dotdotrelative/foo.mjs": "https://example.com/lib/dotdot.mjs" 28 } 29 }, 30 "Import map entries just composed from / and .": { 31 "expectedResults": { 32 "https://example.com/": "https://example.com/lib/slash-only/", 33 "/": "https://example.com/lib/slash-only/", 34 "../": "https://example.com/lib/slash-only/", 35 "https://example.com/app/": "https://example.com/lib/dotslash-only/", 36 "/app/": "https://example.com/lib/dotslash-only/", 37 "../app/": "https://example.com/lib/dotslash-only/" 38 } 39 }, 40 "prefix-matched by keys with trailing slashes": { 41 "expectedResults": { 42 "/test/foo.mjs": "https://example.com/lib/url-trailing-slash/foo.mjs", 43 "https://example.com/app/test/foo.mjs": "https://example.com/lib/url-trailing-slash-dot/foo.mjs" 44 } 45 }, 46 "should use the last entry's address when URL-like specifiers parse to the same absolute URL": { 47 "expectedResults": { 48 "/test": "https://example.com/lib/test2.mjs" 49 } 50 }, 51 "backtracking (relative URLs)": { 52 "expectedResults": { 53 "/test/..": "https://example.com/lib/slash-only/", 54 "/test/../backtrack": "https://example.com/lib/slash-only/backtrack", 55 "/test/../../backtrack": "https://example.com/lib/slash-only/backtrack", 56 "/test/../../../backtrack": "https://example.com/lib/slash-only/backtrack" 57 } 58 }, 59 "backtracking (absolute URLs)": { 60 "expectedResults": { 61 "https://example.com/test/..": "https://example.com/lib/slash-only/", 62 "https://example.com/test/../backtrack": "https://example.com/lib/slash-only/backtrack", 63 "https://example.com/test/../../backtrack": "https://example.com/lib/slash-only/backtrack", 64 "https://example.com/test/../../../backtrack": "https://example.com/lib/slash-only/backtrack" 65 } 66 } 67 } 68 }