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

Owner is parsed incorrectly when GitHub user name is a hex number, e.g., '0xABC' #135

Closed
ronyeh opened this issue Jan 26, 2022 · 2 comments · Fixed by #138 · 4 remaining pull requests
Closed

Owner is parsed incorrectly when GitHub user name is a hex number, e.g., '0xABC' #135

ronyeh opened this issue Jan 26, 2022 · 2 comments · Fixed by #138 · 4 remaining pull requests

Comments

@ronyeh
Copy link

ronyeh commented Jan 26, 2022

Repro:

const GitUrlParse = require("git-url-parse");

const a = GitUrlParse("git@github.com:0xABCDEF/myreponame.git");
const b = GitUrlParse("git@github.com:1xABCDEF/myreponame.git");
const c = GitUrlParse("git@github.com:zxABCDEF/myreponame.git");

console.log(a.owner, a.full_name); // BUGGY => git git/myreponame
console.log(b.owner, b.full_name); // OK => 1xABCDEF 1xABCDEF/myreponame
console.log(c.owner, c.full_name); // OK => zxABCDEF zxABCDEF/myreponame

I have a git url to parse where the owner's GitHub user name is a hexadecimal number. :-)

@ronyeh
Copy link
Author

ronyeh commented Jan 26, 2022

I did more testing, and the bug only occurs when the owner's user name is a string that can be parsed into a number (e.g., a hex string).

git@github.com:0xABCZ/git-url-parse => OK: the owner is parsed a 0xABCZ.
git@github.com:0xABC/git-url-parse => FAIL: the owner is parsed as 'git'.

@ronyeh ronyeh changed the title Owner is parsed incorrectly when GitHub user name starts with zero, e.g., '0xABC' Owner is parsed incorrectly when GitHub user name is a hex number, e.g., '0xABC' Jan 26, 2022
@ronyeh
Copy link
Author

ronyeh commented Jan 26, 2022

I did some further digging... :-) and I found the issue in the parse-path package:

IonicaBizau/parse-path#32

It only happens when the GitHub user name is a string that could be parsed into a number (since parse-path uses the Number(...) function to convert strings to numbers).

So the following GitHub user names and repo urls would fail to be parsed:

0xABC
0b101011
0o1337

git@github.com:0xABC/repo.git
git@github.com:0b101011/repo.git
git@github.com:0o1337/repo.git

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment