Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Import Maps] Make null entries be ignored instead of causing errors #21050

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ describe('Relative URL-like addresses', () => {
}`,
'data:text/html,test',
{
dotSlash: [],
dotDotSlash: [],
slash: []
},
[
`Invalid address "./foo" for the specifier key "dotSlash".`,
Expand Down Expand Up @@ -69,13 +66,6 @@ describe('Relative URL-like addresses', () => {
}`,
'https://base.example/path1/path2/path3',
{
dotSlash1: [],
dotDotSlash1: [],
dotSlash2: [],
dotDotSlash2: [],
slash2: [],
dotSlash3: [],
dotDotSlash3: []
},
[
`Invalid address "%2E/" for the specifier key "dotSlash1".`,
Expand Down Expand Up @@ -110,7 +100,6 @@ describe('Built-in module addresses', () => {
}`,
'https://base.example/path1/path2/path3',
{
foo: []
},
[`Invalid address "${encodeURIComponent(BUILT_IN_MODULE_SCHEME + ':')}foo" for the specifier key "foo".`]
);
Expand Down Expand Up @@ -160,10 +149,6 @@ describe('Absolute URL addresses', () => {
http: [expect.toMatchURL('http://good/')],
https: [expect.toMatchURL('https://good/')],
ftp: [expect.toMatchURL('ftp://good/')],
import: [],
mailto: [],
javascript: [],
wss: []
},
[
`Invalid address "import:bad" for the specifier key "import".`,
Expand Down Expand Up @@ -200,10 +185,6 @@ describe('Absolute URL addresses', () => {
http: [expect.toMatchURL('http://good/')],
https: [expect.toMatchURL('https://good/')],
ftp: [expect.toMatchURL('ftp://good/')],
import: [],
mailto: [],
javascript: [],
wss: []
},
[
`Invalid address "import:bad" for the specifier key "import".`,
Expand All @@ -228,9 +209,6 @@ describe('Absolute URL addresses', () => {
}`,
'https://base.example/path1/path2/path3',
{
unparseable1: [],
unparseable2: [],
unparseable3: [],
invalidButParseable1: [expect.toMatchURL('https://example.org/')],
invalidButParseable2: [expect.toMatchURL('https://example.com///')],
prettyNormal: [expect.toMatchURL('https://example.net/')],
Expand Down Expand Up @@ -259,9 +237,6 @@ describe('Absolute URL addresses', () => {
}`,
'https://base.example/path1/path2/path3',
{
unparseable1: [],
unparseable2: [],
unparseable3: [],
invalidButParseable1: [expect.toMatchURL('https://example.org/')],
invalidButParseable2: [expect.toMatchURL('https://example.com///')],
prettyNormal: [expect.toMatchURL('https://example.net/')],
Expand All @@ -286,8 +261,6 @@ describe('Failing addresses: mismatched trailing slashes', () => {
}`,
'https://base.example/path1/path2/path3',
{
'trailer/': [],
[`${BUILT_IN_MODULE_SCHEME}:trailer/`]: []
},
[
`Invalid address "https://base.example/notrailer" for package specifier key "trailer/". Package addresses must end with "/".`,
Expand All @@ -304,8 +277,6 @@ describe('Failing addresses: mismatched trailing slashes', () => {
}`,
'https://base.example/path1/path2/path3',
{
'trailer/': [],
[`${BUILT_IN_MODULE_SCHEME}:trailer/`]: []
},
[
`Invalid address "https://base.example/notrailer" for package specifier key "trailer/". Package addresses must end with "/".`,
Expand Down Expand Up @@ -342,7 +313,6 @@ describe('Other invalid addresses', () => {
}`,
'https://base.example/path1/path2/path3',
{
foo: []
},
[`Invalid address "${bad}" for the specifier key "foo".`]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,14 @@ describe('Mapped using the "imports" key only (no scopes)', () => {
expect(resolveUnderTest('../dotdotrelative/foo.mjs')).toMatchURL('https://example.com/lib/dotdot.mjs');
});

it('should fail for URLs that remap to empty arrays', () => {
expect(() => resolveUnderTest('https://example.com/lib/no.mjs')).toThrow(TypeError);
expect(() => resolveUnderTest('/lib/no.mjs')).toThrow(TypeError);
expect(() => resolveUnderTest('../lib/no.mjs')).toThrow(TypeError);

expect(() => resolveUnderTest('https://example.com/app/dotrelative/no.mjs')).toThrow(TypeError);
expect(() => resolveUnderTest('/app/dotrelative/no.mjs')).toThrow(TypeError);
expect(() => resolveUnderTest('../app/dotrelative/no.mjs')).toThrow(TypeError);
it('should ignore entries that remap to empty arrays', () => {
expect(resolveUnderTest('https://example.com/lib/no.mjs')).toMatchURL('https://example.com/lib/slash-only/lib/no.mjs');
expect(resolveUnderTest('/lib/no.mjs')).toMatchURL('https://example.com/lib/slash-only/lib/no.mjs');
expect(resolveUnderTest('../lib/no.mjs')).toMatchURL('https://example.com/lib/slash-only/lib/no.mjs');

expect(resolveUnderTest('https://example.com/app/dotrelative/no.mjs')).toMatchURL('https://example.com/lib/dotslash-only/dotrelative/no.mjs');
expect(resolveUnderTest('/app/dotrelative/no.mjs')).toMatchURL('https://example.com/lib/dotslash-only/dotrelative/no.mjs');
expect(resolveUnderTest('../app/dotrelative/no.mjs')).toMatchURL('https://example.com/lib/dotslash-only/dotrelative/no.mjs');
});

it('should remap URLs that are just composed from / and .', () => {
Expand Down Expand Up @@ -261,9 +261,9 @@ describe('Mapped using the "imports" key only (no scopes)', () => {
expect(resolveUnderTest('a')).toMatchURL('https://example.com/1');
expect(resolveUnderTest('a/')).toMatchURL('https://example.com/2/');
expect(resolveUnderTest('a/x')).toMatchURL('https://example.com/2/x');
expect(() => resolveUnderTest('a/b')).toThrow(TypeError);
expect(() => resolveUnderTest('a/b/')).toThrow(TypeError);
expect(() => resolveUnderTest('a/b/c')).toThrow(TypeError);
expect(resolveUnderTest('a/b')).toMatchURL('https://example.com/2/b');
expect(resolveUnderTest('a/b/')).toMatchURL('https://example.com/2/b/');
expect(resolveUnderTest('a/b/c')).toMatchURL('https://example.com/2/b/c');
expect(resolveUnderTest('a/x/c')).toMatchURL('https://example.com/2/x/c');
});
});
Expand Down