Skip to content

Commit d1add60

Browse files
yulerrauchg
authored andcommitted
Update regexp for 10-.5 is invalid input (#117)
1 parent d95e17f commit d1add60

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function parse(str) {
5050
if (str.length > 100) {
5151
return;
5252
}
53-
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(
53+
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(
5454
str
5555
);
5656
if (!match) {

tests.js

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ describe('ms(string)', function() {
5555

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

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

0 commit comments

Comments
 (0)