File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ var parse = require('url').parse
2
2
3
3
module . exports = function ( string ) {
4
4
// user/repo#version
5
- var m = / ^ ( [ \w - ] + ) \/ ( [ \w - . ] + ) ( (?: # | @ ) .+ ) ? $ / . exec ( string )
5
+ var m = / ^ ( [ \w - . ] + ) \/ ( [ \w - . ] + ) ( (?: # | @ ) .+ ) ? $ / . exec ( string )
6
6
if ( m ) return format ( m )
7
7
8
8
string = string . replace ( '//www.' , '//' )
@@ -19,17 +19,17 @@ module.exports = function (string) {
19
19
var path = url . pathname . replace ( / \. g i t $ / , '' )
20
20
21
21
// 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 )
23
23
if ( m ) return m . slice ( 1 , 3 ) . concat ( ( url . hash || '' ) . slice ( 1 ) )
24
24
25
25
// archive link
26
26
// https://developer.github.com/v3/repos/contents/#get-archive-link
27
- var m = / ^ \/ r e p o s \/ ( [ \w - ] + ) \/ ( [ \w - . ] + ) \/ (?: t a r b a l l | z i p b a l l ) ( \/ .+ ) ? $ / . exec ( path )
27
+ var m = / ^ \/ r e p o s \/ ( [ \w - . ] + ) \/ ( [ \w - . ] + ) \/ (?: t a r b a l l | z i p b a l l ) ( \/ .+ ) ? $ / . exec ( path )
28
28
if ( m ) return format ( m )
29
29
30
30
// codeload link
31
31
// https://developer.github.com/v3/repos/contents/#response-4
32
- var m = / ^ \/ ( [ \w - ] + ) \/ ( [ \w - . ] + ) \/ (?: l e g a c y \. (?: z i p | t a r \. g z ) ) ( \/ .+ ) ? $ / . exec ( path )
32
+ var m = / ^ \/ ( [ \w - . ] + ) \/ ( [ \w - . ] + ) \/ (?: l e g a c y \. (?: z i p | t a r \. g z ) ) ( \/ .+ ) ? $ / . exec ( path )
33
33
if ( m ) return format ( m )
34
34
35
35
// tarball link
Original file line number Diff line number Diff line change @@ -50,6 +50,19 @@ describe('versioned', function () {
50
50
} )
51
51
} )
52
52
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
+
53
66
describe ( 'url parse' , function ( ) {
54
67
var builtinUrlParse = require ( 'url' ) . parse
55
68
You can’t perform that action at this time.
0 commit comments