Skip to content

Commit

Permalink
Update regexp for 10-.5 is invalid input (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuler authored and rauchg committed Feb 6, 2019
1 parent d95e17f commit d1add60
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function parse(str) {
if (str.length > 100) {
return;
}
var match = /^((?:\d+)?-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
str
);
if (!match) {
Expand Down
1 change: 1 addition & 0 deletions tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ describe('ms(string)', function() {

it('should return NaN if invalid', function() {
expect(isNaN(ms('☃'))).to.be(true);
expect(isNaN(ms('10-.5'))).to.be(true);
});

it('should be case-insensitive', function() {
Expand Down

0 comments on commit d1add60

Please sign in to comment.