marcello3d / node-tosource

Converts JavaScript objects to source
https://github.com/marcello3d/node-tosource
zlib License
101 stars 16 forks source link

toSource(new RegExp("/slash/killed/me")) #12

Closed kapouer closed 9 years ago

kapouer commented 9 years ago

Hi,

it gives //slash/killed/me/ which isn't evaluable. just got bitten by this, using an old nodejs 0.10 + v8 3.14 version from debian. Maybe 0.12 or io.js don't have that problem (i.e. properly escape regexp toString).

marcello3d commented 9 years ago

Yea, definitely looks like a bug in 0.10:

$ node -v
v2.3.3
$ node
> new RegExp("/slash/killed/me")
/\/slash\/killed\/me/
$ node -v
v0.10.35
$ node
> new RegExp("/slash/killed/me")
//slash/killed/me/

Maybe there's a polyfill that fixes RegExp.prototype.toString? Or you could make one. :-)

kapouer commented 9 years ago

Yes, i'll PR that later

kapouer commented 9 years ago

It's fixed, then. I don't want to force the hand, but maybe you can release this ?

marcello3d commented 9 years ago

@kapouer released as v1.0.0! added standard and updated the travis config, so let me know if this is working for you now

kapouer commented 9 years ago

It works all right, thank you.