Skip to content

Commit

Permalink
feat(all): Support www. prefixes on hostnames
Browse files Browse the repository at this point in the history
Fixes: #32
  • Loading branch information
iarna committed Jul 6, 2018
1 parent 701bcd1 commit 3349575
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function fromUrl (giturl, opts) {
project = decodeURIComponent(shortcutMatch[3])
defaultRepresentation = 'shortcut'
} else {
if (parsed.host !== gitHostInfo.domain) return
if (parsed.host !== gitHostInfo.domain && parsed.host.replace(/^www[.]/, '') !== gitHostInfo.domain) return

This comment has been minimized.

Copy link
@Erveon

Erveon Jul 7, 2018

Contributor

This causes TypeError: Cannot read property 'replace' of null for certain libraries.

if (!gitHostInfo.protocols_re.test(parsed.protocol)) return
if (!parsed.path) return
var pathmatch = gitHostInfo.pathmatch
Expand Down
1 change: 1 addition & 0 deletions test/bitbucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ test('fromUrl(bitbucket url)', function (t) {
}

require('./lib/standard-tests')(verify, 'bitbucket.org', 'bitbucket')
require('./lib/standard-tests')(verify, 'www.bitbucket.org', 'bitbucket')

t.end()
})
2 changes: 2 additions & 0 deletions test/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,7 @@ test('fromUrl(github url)', function (t) {

require('./lib/standard-tests')(verify, 'github.com', 'github')

require('./lib/standard-tests')(verify, 'www.github.com', 'github')

t.end()
})
1 change: 1 addition & 0 deletions test/gitlab.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ test('fromUrl(gitlab url)', function (t) {
}

require('./lib/standard-tests')(verify, 'gitlab.com', 'gitlab')
require('./lib/standard-tests')(verify, 'www.gitlab.com', 'gitlab')

t.end()
})

0 comments on commit 3349575

Please sign in to comment.