summaryrefslogtreecommitdiff
path: root/cli/npm/registry.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/npm/registry.rs')
-rw-r--r--cli/npm/registry.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/cli/npm/registry.rs b/cli/npm/registry.rs
index 40d7f6219..eb0a2068a 100644
--- a/cli/npm/registry.rs
+++ b/cli/npm/registry.rs
@@ -363,7 +363,23 @@ impl CliNpmRegistryApiInner {
}
fn get_package_url(&self, name: &str) -> Url {
- self.base_url.join(name).unwrap()
+ // list of all characters used in npm packages:
+ // !, ', (, ), *, -, ., /, [0-9], @, [A-Za-z], _, ~
+ const ASCII_SET: percent_encoding::AsciiSet =
+ percent_encoding::NON_ALPHANUMERIC
+ .remove(b'!')
+ .remove(b'\'')
+ .remove(b'(')
+ .remove(b')')
+ .remove(b'*')
+ .remove(b'-')
+ .remove(b'.')
+ .remove(b'/')
+ .remove(b'@')
+ .remove(b'_')
+ .remove(b'~');
+ let name = percent_encoding::utf8_percent_encode(name, &ASCII_SET);
+ self.base_url.join(&name.to_string()).unwrap()
}
fn get_package_file_cache_path(&self, name: &str) -> PathBuf {