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

Return the correct host for git@ URLs #11

Merged
merged 1 commit into from
Nov 1, 2017

Conversation

cookpete
Copy link
Contributor

Fixes #10

Node's built in url function doesn't seem to return the correct host for git@* urls:

λ node -e "console.log(require('url').parse('git@gh.pages.com:assemble/verb.git'))"
Url {
  protocol: null,
  slashes: null,
  auth: null,
  host: null,
  port: null,
  hostname: null,
  hash: null,
  search: null,
  query: null,
  pathname: 'git@gh.pages.com:assemble/verb.git',
  path: 'git@gh.pages.com:assemble/verb.git',
  href: 'git@gh.pages.com:assemble/verb.git' }

But it does if you stick a valid protocol in front:

λ node -e "console.log(require('url').parse('http://git@gh.pages.com:assemble/verb.git'))"
Url {
  protocol: 'http:',
  slashes: true,
  auth: 'git',
  host: 'gh.pages.com',
  port: null,
  hostname: 'gh.pages.com',
  hash: null,
  search: null,
  query: null,
  pathname: '/:assemble/verb.git',
  path: '/:assemble/verb.git',
  href: 'http://git@gh.pages.com/:assemble/verb.git' }

This PR checks if host is empty and the URL start with git@ and parses the URL with http:// prepended, to give us the correct host.

Tests added, and all existing tests pass.

@jonschlinkert jonschlinkert merged commit ec38e82 into jonschlinkert:master Nov 1, 2017
@jonschlinkert
Copy link
Owner

published and released as 1.0.1, thanks!

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

Successfully merging this pull request may close these issues.

2 participants