]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Fix function check to workaround old browsers, fixes #2325
authorIskren Chernev <iskren.chernev@gmail.com>
Wed, 8 Jul 2015 11:20:53 +0000 (19:20 +0800)
committerIskren Chernev <iskren.chernev@gmail.com>
Mon, 13 Jul 2015 00:40:49 +0000 (17:40 -0700)
src/lib/parse/regex.js

index 23091a08352ff036ba5e4546e04861f956d3b506..9e7d6788c925ca84e9c7132fd35734354f32a09f 100644 (file)
@@ -22,8 +22,15 @@ import hasOwnProp from '../utils/has-own-prop';
 
 var regexes = {};
 
+function isFunction (sth) {
+    // https://github.com/moment/moment/issues/2325
+    return typeof sth === 'function' &&
+        Object.prototype.toString.call(sth) === '[object Function]';
+}
+
+
 export function addRegexToken (token, regex, strictRegex) {
-    regexes[token] = typeof regex === 'function' ? regex : function (isStrict) {
+    regexes[token] = isFunction(regex) ? regex : function (isStrict) {
         return (isStrict && strictRegex) ? strictRegex : regex;
     };
 }