Skip to content

Commit

Permalink
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 9011b14 commit ced9cce
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
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 ced9cce

Please sign in to comment.