shorthand urls no longer parsable in v8
Closed this issue · 2 comments
privatenumber commented
In https://github.com/IonicaBizau/git-url-parse, parseUrl is expected to be parse shorthand GitHub URLs:
parseUrl('42IonicaBizau/git-url-parse')
In v7:
{
protocols: [ 'file' ],
protocol: 'file',
port: '',
resource: '',
user: '',
password: '',
pathname: '',
hash: '',
search: '',
href: '42IonicaBizau/git-url-parse',
query: {}
}
However, v8 introduces a regression where this no longer works:
Error: URL parsing failed.
at async ESMLoader.import (https://node-xtnz8w.w.staticblitz.com/blitz.1f021b18268b32e6c6b2095e039ac8c9f88b0d52.js:6:1209040)
at async i.loadESM (https://node-xtnz8w.w.staticblitz.com/blitz.1f021b18268b32e6c6b2095e039ac8c9f88b0d52.js:6:246622)
at async handleMainPromise (https://node-xtnz8w.w.staticblitz.com/blitz.1f021b18268b32e6c6b2095e039ac8c9f88b0d52.js:6:989049) {
subject_url: '42IonicaBizau/git-url-parse'
}
Reproduction:
https://stackblitz.com/edit/node-xtnz8w?file=package.json&view=editor
privatenumber commented
Alternatively, we can handle this new output better in git-url-parse
. After all, user/repo
is not a URL so the logic should probably not live here.
We can directly parse out a GitHub shorthand URL with a pattern like this:
const usernamePattern = /[a-z\d-]{1,39}/i;
const repositoryNamePattern = /[-\.\w]{1,100}/;
IonicaBizau commented
@privatenumber I think this should be handled in git-url-parse
indeed. parse-url
should not really know about aliasing these with any service (such as GitHub). Contributions are welcome in git-url-parse
! 😁