Commits

Radomir Dopieralski committed b94a86a

when no cookie, default to ""

Comments (0)

Files changed (1)

         name = escape(name);
         name = name.replace(/[\-\.\+\*]/g, "\\$&");
         var re = "(?:^|.*;\\s*)" + name + "\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";
-        var value = document.cookie.replace(new RegExp(re), "$1");
+        var re = new RegExp(re);
+        if (!re.test(document.cookie)) {
+            return "";
+        };
+        var value = document.cookie.replace(re, "$1");
         console.log(document.cookie);
         console.log(value);
         value = unescape(value);