scopes-exact-vs-prefix.json (4591B)
1 { 2 "name": "Exact vs. prefix based matching", 3 "details": "Scopes are matched with base URLs that are exactly the same or subpaths under the scopes with trailing shashes", 4 "link": "https://wicg.github.io/import-maps/#resolve-a-module-specifier Step 8.1", 5 "tests": { 6 "Scope without trailing slash only": { 7 "importMap": { 8 "scopes": { 9 "/js": { 10 "moment": "/only-triggered-by-exact/moment", 11 "moment/": "/only-triggered-by-exact/moment/" 12 } 13 } 14 }, 15 "importMapBaseURL": "https://example.com/app/index.html", 16 "tests": { 17 "Non-trailing-slash base URL (exact match)": { 18 "baseURL": "https://example.com/js", 19 "expectedResults": { 20 "moment": "https://example.com/only-triggered-by-exact/moment", 21 "moment/foo": "https://example.com/only-triggered-by-exact/moment/foo" 22 } 23 }, 24 "Trailing-slash base URL (fail)": { 25 "baseURL": "https://example.com/js/", 26 "expectedResults": { 27 "moment": null, 28 "moment/foo": null 29 } 30 }, 31 "Subpath base URL (fail)": { 32 "baseURL": "https://example.com/js/app.mjs", 33 "expectedResults": { 34 "moment": null, 35 "moment/foo": null 36 } 37 }, 38 "Non-subpath base URL (fail)": { 39 "baseURL": "https://example.com/jsiscool", 40 "expectedResults": { 41 "moment": null, 42 "moment/foo": null 43 } 44 } 45 } 46 }, 47 "Scope with trailing slash only": { 48 "importMap": { 49 "scopes": { 50 "/js/": { 51 "moment": "/triggered-by-any-subpath/moment", 52 "moment/": "/triggered-by-any-subpath/moment/" 53 } 54 } 55 }, 56 "importMapBaseURL": "https://example.com/app/index.html", 57 "tests": { 58 "Non-trailing-slash base URL (fail)": { 59 "baseURL": "https://example.com/js", 60 "expectedResults": { 61 "moment": null, 62 "moment/foo": null 63 } 64 }, 65 "Trailing-slash base URL (exact match)": { 66 "baseURL": "https://example.com/js/", 67 "expectedResults": { 68 "moment": "https://example.com/triggered-by-any-subpath/moment", 69 "moment/foo": "https://example.com/triggered-by-any-subpath/moment/foo" 70 } 71 }, 72 "Subpath base URL (prefix match)": { 73 "baseURL": "https://example.com/js/app.mjs", 74 "expectedResults": { 75 "moment": "https://example.com/triggered-by-any-subpath/moment", 76 "moment/foo": "https://example.com/triggered-by-any-subpath/moment/foo" 77 } 78 }, 79 "Non-subpath base URL (fail)": { 80 "baseURL": "https://example.com/jsiscool", 81 "expectedResults": { 82 "moment": null, 83 "moment/foo": null 84 } 85 } 86 } 87 }, 88 "Scopes with and without trailing slash": { 89 "importMap": { 90 "scopes": { 91 "/js": { 92 "moment": "/only-triggered-by-exact/moment", 93 "moment/": "/only-triggered-by-exact/moment/" 94 }, 95 "/js/": { 96 "moment": "/triggered-by-any-subpath/moment", 97 "moment/": "/triggered-by-any-subpath/moment/" 98 } 99 } 100 }, 101 "importMapBaseURL": "https://example.com/app/index.html", 102 "tests": { 103 "Non-trailing-slash base URL (exact match)": { 104 "baseURL": "https://example.com/js", 105 "expectedResults": { 106 "moment": "https://example.com/only-triggered-by-exact/moment", 107 "moment/foo": "https://example.com/only-triggered-by-exact/moment/foo" 108 } 109 }, 110 "Trailing-slash base URL (exact match)": { 111 "baseURL": "https://example.com/js/", 112 "expectedResults": { 113 "moment": "https://example.com/triggered-by-any-subpath/moment", 114 "moment/foo": "https://example.com/triggered-by-any-subpath/moment/foo" 115 } 116 }, 117 "Subpath base URL (prefix match)": { 118 "baseURL": "https://example.com/js/app.mjs", 119 "expectedResults": { 120 "moment": "https://example.com/triggered-by-any-subpath/moment", 121 "moment/foo": "https://example.com/triggered-by-any-subpath/moment/foo" 122 } 123 }, 124 "Non-subpath base URL (fail)": { 125 "baseURL": "https://example.com/jsiscool", 126 "expectedResults": { 127 "moment": null, 128 "moment/foo": null 129 } 130 } 131 } 132 } 133 } 134 }