marcello3d / node-tosource

Converts JavaScript objects to source

Home Page:https://github.com/marcello3d/node-tosource

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

kapouer opened this issue · comments

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).

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. :-)

Yes, i'll PR that later

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

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

It works all right, thank you.