Skip to content

Commit 52c8b01

Browse files
committed
added support for www domain
1 parent 38adb11 commit 52c8b01

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = function (string) {
66
var m = /^([\w-]+)\/([\w-.]+)((?:#|@).+)?$/.exec(string)
77
if (m) return format(m)
88

9+
string = string.replace('//www.', '//')
910
// normalize git@ and https:git@ urls
1011
string = string.replace(/^git@/, 'https://')
1112
string = string.replace(/^https:git@/, 'https://')

test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ describe('versionless', function () {
1717
assert.deepEqual(['component', 'emitter', ''], parse(url))
1818
})
1919
})
20+
21+
it('works for www.github.com', function () {
22+
var url = 'https://www.github.com/component/emitter'
23+
var parsed = parse(url)
24+
assert.deepEqual(['component', 'emitter', ''], parsed)
25+
})
26+
27+
it('works for http://www.github.com', function () {
28+
var url = 'http://www.github.com/component/emitter'
29+
var parsed = parse(url)
30+
assert.deepEqual(['component', 'emitter', ''], parsed)
31+
})
2032
})
2133

2234
describe('versioned', function () {

0 commit comments

Comments
 (0)