ScottHamper/Cookies — pull request #27 by sunteya (2014-07-02 04:22:56+00:00)
Title: avoid pass native function to string.replace

I use the cookies-js in a STB project. It contains an old and quirky browser(called ipanel).

If use string.replace and pass native function, it will like this:

~~~~javascript
var a = "12345".replace(/4/, encodeURIComponent);
alert(a); // print 123encodeURIComponent(){ [native code]}5
~~~~

It must wrap the native function.

~~~~javascript
var a = "12345".replace(/4/,function(s) { return encodeURIComponent(s) });
alert(a); // print 12345
~~~~