Skip to content

Commit 3349575

Browse files
committed
feat(all): Support www. prefixes on hostnames
Fixes: #32
1 parent 701bcd1 commit 3349575

File tree

4 files changed

+5
-1
lines changed

4 files changed

+5
-1
lines changed

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function fromUrl (giturl, opts) {
5858
project = decodeURIComponent(shortcutMatch[3])
5959
defaultRepresentation = 'shortcut'
6060
} else {
61-
if (parsed.host !== gitHostInfo.domain) return
61+
if (parsed.host !== gitHostInfo.domain && parsed.host.replace(/^www[.]/, '') !== gitHostInfo.domain) return
6262
if (!gitHostInfo.protocols_re.test(parsed.protocol)) return
6363
if (!parsed.path) return
6464
var pathmatch = gitHostInfo.pathmatch

test/bitbucket.js

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ test('fromUrl(bitbucket url)', function (t) {
2121
}
2222

2323
require('./lib/standard-tests')(verify, 'bitbucket.org', 'bitbucket')
24+
require('./lib/standard-tests')(verify, 'www.bitbucket.org', 'bitbucket')
2425

2526
t.end()
2627
})

test/github.js

+2
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,7 @@ test('fromUrl(github url)', function (t) {
3939

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

42+
require('./lib/standard-tests')(verify, 'www.github.com', 'github')
43+
4244
t.end()
4345
})

test/gitlab.js

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ test('fromUrl(gitlab url)', function (t) {
2121
}
2222

2323
require('./lib/standard-tests')(verify, 'gitlab.com', 'gitlab')
24+
require('./lib/standard-tests')(verify, 'www.gitlab.com', 'gitlab')
2425

2526
t.end()
2627
})

0 commit comments

Comments
 (0)