diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2022-05-02 09:07:41 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-02 09:07:41 -0400 |
commit | e099ddb87c9c4198a425ea63c6dec0ce6eddb40b (patch) | |
tree | c9684422c3c20b7290e0619904929dd12527dfff /cli/tools/vendor/build.rs | |
parent | 1d51b1649e75b8d2e8ca81c9aab08c9f119a6ab5 (diff) |
fix(vendor): do not panic on relative specifier with scheme-like folder name (#14453)
Diffstat (limited to 'cli/tools/vendor/build.rs')
-rw-r--r-- | cli/tools/vendor/build.rs | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/cli/tools/vendor/build.rs b/cli/tools/vendor/build.rs index 260aa39f5..0e42edb4a 100644 --- a/cli/tools/vendor/build.rs +++ b/cli/tools/vendor/build.rs @@ -619,6 +619,55 @@ mod test { ); } + #[tokio::test] + async fn remote_relative_specifier_with_scheme_like_folder_name() { + let mut builder = VendorTestBuilder::with_default_setup(); + let output = builder + .with_loader(|loader| { + loader + .add("/mod.ts", "import 'https://localhost/mod.ts';") + .add( + "https://localhost/mod.ts", + "import './npm:test@1.0.0/test/test!cjs';", + ) + .add_with_headers( + "https://localhost/npm:test@1.0.0/test/test!cjs", + "console.log(5);", + &[("content-type", "application/javascript")], + ); + }) + .build() + .await + .unwrap(); + + assert_eq!( + output.import_map, + Some(json!({ + "imports": { + "https://localhost/": "./localhost/" + }, + "scopes": { + "./localhost/": { + "./localhost/npm:test@1.0.0/test/test!cjs": "./localhost/npm_test@1.0.0/test/test!cjs.js" + } + } + })) + ); + assert_eq!( + output.files, + to_file_vec(&[ + ( + "/vendor/localhost/mod.ts", + "import './npm:test@1.0.0/test/test!cjs';" + ), + ( + "/vendor/localhost/npm_test@1.0.0/test/test!cjs.js", + "console.log(5);" + ), + ]), + ); + } + fn to_file_vec(items: &[(&str, &str)]) -> Vec<(String, String)> { items .iter() |