Very Popular
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135{ "name": "Exact vs. prefix based matching", "details": "Scopes are matched with base URLs that are exactly the same or subpaths under the scopes with trailing shashes", "link": "https://wicg.github.io/import-maps/#resolve-a-module-specifier Step 8.1", "tests": { "Scope without trailing slash only": { "importMap": { "scopes": { "/js": { "moment": "/only-triggered-by-exact/moment", "moment/": "/only-triggered-by-exact/moment/" } } }, "importMapBaseURL": "https://example.com/app/index.html", "tests": { "Non-trailing-slash base URL (exact match)": { "baseURL": "https://example.com/js", "expectedResults": { "moment": "https://example.com/only-triggered-by-exact/moment", "moment/foo": "https://example.com/only-triggered-by-exact/moment/foo" } }, "Trailing-slash base URL (fail)": { "baseURL": "https://example.com/js/", "expectedResults": { "moment": null, "moment/foo": null } }, "Subpath base URL (fail)": { "baseURL": "https://example.com/js/app.mjs", "expectedResults": { "moment": null, "moment/foo": null } }, "Non-subpath base URL (fail)": { "baseURL": "https://example.com/jsiscool", "expectedResults": { "moment": null, "moment/foo": null } } } }, "Scope with trailing slash only": { "importMap": { "scopes": { "/js/": { "moment": "/triggered-by-any-subpath/moment", "moment/": "/triggered-by-any-subpath/moment/" } } }, "importMapBaseURL": "https://example.com/app/index.html", "tests": { "Non-trailing-slash base URL (fail)": { "baseURL": "https://example.com/js", "expectedResults": { "moment": null, "moment/foo": null } }, "Trailing-slash base URL (exact match)": { "baseURL": "https://example.com/js/", "expectedResults": { "moment": "https://example.com/triggered-by-any-subpath/moment", "moment/foo": "https://example.com/triggered-by-any-subpath/moment/foo" } }, "Subpath base URL (prefix match)": { "baseURL": "https://example.com/js/app.mjs", "expectedResults": { "moment": "https://example.com/triggered-by-any-subpath/moment", "moment/foo": "https://example.com/triggered-by-any-subpath/moment/foo" } }, "Non-subpath base URL (fail)": { "baseURL": "https://example.com/jsiscool", "expectedResults": { "moment": null, "moment/foo": null } } } }, "Scopes with and without trailing slash": { "importMap": { "scopes": { "/js": { "moment": "/only-triggered-by-exact/moment", "moment/": "/only-triggered-by-exact/moment/" }, "/js/": { "moment": "/triggered-by-any-subpath/moment", "moment/": "/triggered-by-any-subpath/moment/" } } }, "importMapBaseURL": "https://example.com/app/index.html", "tests": { "Non-trailing-slash base URL (exact match)": { "baseURL": "https://example.com/js", "expectedResults": { "moment": "https://example.com/only-triggered-by-exact/moment", "moment/foo": "https://example.com/only-triggered-by-exact/moment/foo" } }, "Trailing-slash base URL (exact match)": { "baseURL": "https://example.com/js/", "expectedResults": { "moment": "https://example.com/triggered-by-any-subpath/moment", "moment/foo": "https://example.com/triggered-by-any-subpath/moment/foo" } }, "Subpath base URL (prefix match)": { "baseURL": "https://example.com/js/app.mjs", "expectedResults": { "moment": "https://example.com/triggered-by-any-subpath/moment", "moment/foo": "https://example.com/triggered-by-any-subpath/moment/foo" } }, "Non-subpath base URL (fail)": { "baseURL": "https://example.com/jsiscool", "expectedResults": { "moment": null, "moment/foo": null } } } } }}