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
22
33module . 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 ( / \. g i t $ / , '' )
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 = / ^ \/ 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 )
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 - . ] + ) \/ (?: 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 )
3333 if ( m ) return format ( m )
3434
3535 // tarball link
Original file line number Diff line number Diff line change @@ -50,6 +50,19 @@ describe('versioned', function () {
5050 } )
5151} )
5252
53+ describe ( 'dotted user' , function ( ) {
54+ [
55+ 'my.component/emitter' ,
56+ 'https://github.com/my.component/emitter' ,
57+ 'https://github.com/repos/my.component/emitter/tarball' ,
58+ 'https://codeload.github.com/my.component/emitter/legacy.zip' ,
59+ ] . forEach ( function ( url ) {
60+ it ( url , function ( ) {
61+ assert . deepEqual ( [ 'my.component' , 'emitter' , '' ] , parse ( url ) )
62+ } )
63+ } )
64+ } )
65+
5366describe ( 'url parse' , function ( ) {
5467 var builtinUrlParse = require ( 'url' ) . parse
5568
You can’t perform that action at this time.
0 commit comments