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

Fix host parsing for file URLs #210

merged 1 commit into from Jul 25, 2021


Copy link

@lpinca lpinca commented Jul 25, 2021

Fixes: #209 (comment)

Copy link
Member Author

@lpinca lpinca commented Jul 25, 2021

Anyway url-parse does not do any validation:

> parse('file://host:123/foo/bar/baz')
  slashes: true,
  protocol: 'file:',
  hash: '',
  query: '',
  pathname: '/foo/bar/baz',
  auth: '',
  host: 'host',
  port: '',
  hostname: 'host',
  password: '',
  username: '',
  origin: 'null',
  href: 'file://host/foo/bar/baz'

The Node.js WHATWG URL parser throws an error for the same URL:

> new URL('file://host:123/foo/bar/baz')
Uncaught TypeError [ERR_INVALID_URL]: Invalid URL
    at __node_internal_captureLargerStackTrace (node:internal/errors:463:5)
    at new NodeError (node:internal/errors:370:5)
    at onParseError (node:internal/url:536:9)
    at new URL (node:internal/url:612:5) {
  input: 'file://host:123/foo/bar/baz',

@lpinca lpinca requested a review from 3rd-Eden Jul 25, 2021
enahum approved these changes Jul 25, 2021
@3rd-Eden 3rd-Eden merged commit c798461 into master Jul 25, 2021
9 checks passed
@lpinca lpinca deleted the fix/host-parsing-for-file-urls branch Jul 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants