-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
fix(install): fix the case that package scope contains tilde. #7049
Conversation
huh that is expected to work? interesting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this code should check that the path name between @
and /
is a valid URL component.
Something like this:
pub fn hasURLComponentThatNeedsEncoding(str: []const u8) bool {
const do_not_escape_when_encoding_uri_component = comptime brk: {
// encodeURIComponent uses this table:
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ++
"abcdefghijklmnopqrstuvwxyz" ++
"0123456789" ++
"!'()*-._~";
var bitset = std.bit_set.IntegerBitSet(std.math.maxInt(u8)).initFull();
for (chars) |char| {
bitset.unset(@as(u8, char));
}
break :brk bitset;
};
for (str) |char| {
if (do_not_escape_when_encoding_uri_component.isSet(char)) {
return true;
}
}
return false;
}
npm uses encodeURIComponent
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', '-', '_', '.' => {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I rewrite these switch branches to bitmap?
Thank you! |
What does this PR do?
Close #7045
How did you verify your code works?
I wrote automated tests