Skip to content

Commit

Permalink
Add word boundary check to period tokenizer regex.
Browse files Browse the repository at this point in the history
When only a millisecond based period is provided (e.g. "45 milliseconds"), the period is recognized as minutes ("45m").
This commit adds a word boundary check to the tokenizer regex to distinguish between minutes and milliseconds.
  • Loading branch information
fschaefer committed Sep 28, 2012
1 parent 5a8edb9 commit e897c5b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion timed.js
Expand Up @@ -42,7 +42,7 @@

if (isNaN(parseInt(period,10))) period = '1'+period;

var match = period.toLowerCase().replace(/[^a-z0-9\.]/g, "").match(/(?:(\d+(?:\.\d+)?)(?:days?|d))?(?:(\d+(?:\.\d+)?)(?:hours?|hrs?|h))?(?:(\d+(?:\.\d+)?)(?:minutes?|mins?|m))?(?:(\d+(?:\.\d+)?)(?:seconds?|secs?|s))?(?:(\d+(?:\.\d+)?)(?:milliseconds?|ms))?/);
var match = period.toLowerCase().replace(/[^a-z0-9\.]/g, "").match(/(?:(\d+(?:\.\d+)?)(?:days?|d))?(?:(\d+(?:\.\d+)?)(?:hours?|hrs?|h))?(?:(\d+(?:\.\d+)?)(?:minutes?|mins?|m\b))?(?:(\d+(?:\.\d+)?)(?:seconds?|secs?|s))?(?:(\d+(?:\.\d+)?)(?:milliseconds?|ms))?/);

if (match[0]) {
parsed.when =
Expand Down

0 comments on commit e897c5b

Please sign in to comment.