Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update regexp for 10-.5 is invalid input #117

Merged
merged 1 commit into from Feb 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
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
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