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

shorthand urls no longer parsable in v8 #62

Closed
privatenumber opened this issue Aug 3, 2022 · 2 comments
Closed

shorthand urls no longer parsable in v8 #62

privatenumber opened this issue Aug 3, 2022 · 2 comments

Comments

@privatenumber
Copy link
Contributor

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
Copy link
Contributor Author

privatenumber commented Aug 3, 2022

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
Copy link
Owner

@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! 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants