Closed ticky closed 7 years ago
I’ve had some trouble with one of the existing tests - I must’ve missed something here;
17 passing (43ms)
1 failing
1) regexgen should escape meta characters:
AssertionError [ERR_ASSERTION]: /foo|bar[test]+/ deepEqual /foo\|bar\[test\]\+/
+ expected - actual
-/foo|bar[test]+/
+/foo\|bar\[test\]\+/
at Context.<anonymous> (test/test.js:34:12)
I don’t think anything I did should’ve changed such escaping behaviour. I couldn’t find the source of the bug!
Thanks to @sj26’s sharp eye, I’ve updated this and it now passes all the original specs, and I’ve added a couple of extras 😃🎉
Thanks for your constructive input on this, @devongovett 😃
As part of trying to integrate the new behaviour in mathiasbynens/emoji-regex, I found a little bug, which I fixed in b737de8!
I think I lack compatibility with the changes from #16. Oops!
I’ve added the spec and change you requested, and also added a spec for the failure I was seeing downstream in mathiasbynens/emoji-regex#22, which now appears to be corrected 😃
Thanks again for your patience and your fantastic help!
@ticky thanks so much, awesome work on this! Released in v1.3.0. 🎉
This is a polished up version of what I was working on as part of #15; it updates regexgen to optionally output ES6-compatible Unicode regexes.
It does this by looking at the flags passed; if
u
is included, it outputs a Unicode regex rather than an UCS-2 style regex, by passing the requisite options down toregenerate
andjsesc
.~This isn’t the cleanest change, as no state was previously passed down into the AST methods, so it required quite a bit of passing around. I also only added the additional arguments to the AST object classes affected by the change!~ State is no longer passed down into AST constructors as of 7b560c7, instead being passed to
toString
methods to control their behaviour directly!fixes #15
Todo: