diff --git a/index.js b/index.js index a1d2ea4..a2d1969 100644 --- a/index.js +++ b/index.js @@ -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) { diff --git a/tests.js b/tests.js index 9427390..9141689 100644 --- a/tests.js +++ b/tests.js @@ -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() {