mirror of
https://github.com/oven-sh/bun
synced 2026-02-16 13:51:47 +00:00
fix(install): fix the case that package scope contains tilde. (#7049)
* fix(install): fix the case that package name contains tilde. Close: #7045 * add tests * emm, let me know why test failed * overwrite registry config * check more chars * remove $
This commit is contained in:
@@ -144,16 +144,23 @@ pub inline fn isNPMPackageName(target: string) bool {
|
||||
'@' => true,
|
||||
else => return false,
|
||||
};
|
||||
|
||||
var slash_index: usize = 0;
|
||||
for (target[1..], 0..) |c, i| {
|
||||
switch (c) {
|
||||
// Old packages may have capital letters
|
||||
'A'...'Z', 'a'...'z', '0'...'9', '$', '-', '_', '.' => {},
|
||||
'A'...'Z', 'a'...'z', '0'...'9', '-', '_', '.' => {},
|
||||
'/' => {
|
||||
if (!scoped) return false;
|
||||
if (slash_index > 0) return false;
|
||||
slash_index = i + 1;
|
||||
},
|
||||
// issue#7045, package "@~3/svelte_mount"
|
||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent#description
|
||||
// It escapes all characters except: A–Z a–z 0–9 - _ . ! ~ * ' ( )
|
||||
'!', '~', '*', '\'', '(', ')' => {
|
||||
if (!scoped or slash_index > 0) return false;
|
||||
},
|
||||
else => return false,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user