Skip to content

Commit a3c2558

Browse files
fix: add support for GitLab dotted user
1 parent 9394956 commit a3c2558

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var parse = require('url').parse
22

33
module.exports = function (string) {
44
// user/repo#version
5-
var m = /^([\w-]+)\/([\w-.]+)((?:#|@).+)?$/.exec(string)
5+
var m = /^([\w-.]+)\/([\w-.]+)((?:#|@).+)?$/.exec(string)
66
if (m) return format(m)
77

88
string = string.replace('//www.', '//')
@@ -19,17 +19,17 @@ module.exports = function (string) {
1919
var path = url.pathname.replace(/\.git$/, '')
2020

2121
// https://www.npmjs.org/doc/json.html#Git-URLs-as-Dependencies
22-
var m = /^\/([\w-]+)\/([\w-.]+)$/.exec(path)
22+
var m = /^\/([\w-.]+)\/([\w-.]+)$/.exec(path)
2323
if (m) return m.slice(1, 3).concat((url.hash || '').slice(1))
2424

2525
// archive link
2626
// https://developer.github.com/v3/repos/contents/#get-archive-link
27-
var m = /^\/repos\/([\w-]+)\/([\w-.]+)\/(?:tarball|zipball)(\/.+)?$/.exec(path)
27+
var m = /^\/repos\/([\w-.]+)\/([\w-.]+)\/(?:tarball|zipball)(\/.+)?$/.exec(path)
2828
if (m) return format(m)
2929

3030
// codeload link
3131
// https://developer.github.com/v3/repos/contents/#response-4
32-
var m = /^\/([\w-]+)\/([\w-.]+)\/(?:legacy\.(?:zip|tar\.gz))(\/.+)?$/.exec(path)
32+
var m = /^\/([\w-.]+)\/([\w-.]+)\/(?:legacy\.(?:zip|tar\.gz))(\/.+)?$/.exec(path)
3333
if (m) return format(m)
3434

3535
// tarball link

test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,19 @@ describe('versioned', function () {
5050
})
5151
})
5252

53+
describe('dotted user', function () {
54+
[
55+
'my.component/my.emitter',
56+
'https://github.com/my.component/my.emitter',
57+
'https://github.com/repos/my.component/my.emitter/tarball',
58+
'https://codeload.github.com/my.component/my.emitter/legacy.zip',
59+
].forEach(function (url) {
60+
it(url, function () {
61+
assert.deepEqual(['my.component', 'my.emitter', ''], parse(url))
62+
})
63+
})
64+
})
65+
5366
describe('url parse', function () {
5467
var builtinUrlParse = require('url').parse
5568

0 commit comments

Comments
 (0)