Skip to content

Commit

Permalink
Merge pull request #40 from elrrrrrrr/fix/fixUnderscore
Browse files Browse the repository at this point in the history
Fix/fix underscore
  • Loading branch information
soda-x committed Dec 14, 2015
2 parents 2cdf11b + a842ed6 commit aa12ad0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/util.js
Expand Up @@ -2,8 +2,8 @@

var debug = require('debug')('spm-client:util');

var ID_REGEX = /^([a-z][a-z0-9\-\.]*)(?:@(.+))?$/;
var NAME_REGEX = /^[a-z][a-z0-9\-\.]*$/;
var ID_REGEX = /^([a-z][a-z0-9\-\._]*)(?:@(.+))?$/;
var NAME_REGEX = /^[a-z][a-z0-9\-\._]*$/;

exports.errorHandle = errorHandle;
exports.resolveid = resolveid;
Expand Down
2 changes: 1 addition & 1 deletion test/publish.test.js
Expand Up @@ -104,7 +104,7 @@ describe('/lib/publish.js', function() {
} catch(e) {
err = e;
}
err.message.should.eql('name is invalid, should match /^[a-z][a-z0-9\\-\\.]*$/');
err.message.should.eql('name is invalid, should match /^[a-z][a-z0-9\\-\\._]*$/');

try {
err = undefined;
Expand Down
7 changes: 7 additions & 0 deletions test/util.test.js
Expand Up @@ -17,4 +17,11 @@ describe('/lib/util.js', function() {
(util.resolveid('@1.0.0') === null).should.be.true;
(util.resolveid('_@1.0.0') === null).should.be.true;
});

it('should resolve id contains underscore', function* () {
util.resolveid('lodash._getnative@1.0').should.eql({
name: 'lodash._getnative',
version: '1.0'
});
});
});

0 comments on commit aa12ad0

Please sign in to comment.