]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
use full-string match to speed up C# duration match 2939/head
authorRod Vagg <rod@vagg.org>
Tue, 2 Feb 2016 07:01:31 +0000 (18:01 +1100)
committerRod Vagg <rod@vagg.org>
Tue, 2 Feb 2016 10:37:16 +0000 (21:37 +1100)
Fixes: https://github.com/moment/moment/issues/2936
src/lib/duration/create.js

index a79feea319cf35cc47794a625787bf257fbde16e..d465cee97c900af47384edbefc9d8d11b5514c74 100644 (file)
@@ -6,7 +6,7 @@ import { cloneWithOffset } from '../units/offset';
 import { createLocal } from '../create/local';
 
 // ASP.NET json date format regex
-var aspNetRegex = /(\-)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/;
+var aspNetRegex = /^(\-)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?\d*)?$/;
 
 // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
 // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere