You'll notice that I call the prepPath function twice in a row, passing in the exact same string. In firefox and IE8, this function alerts true each time (as expected). But, in Chromium 5.0.375.127 (55887) Ubuntu 10.04, the function returns true the first time, and false the 2nd call, despite the input remaining exactly the same!
Why is it returning false the second time in Chromium?
There's some ambiguity in the spec about when literal regexes should get reset (recall that they have state). You can work around this by doing this:
var regX = new RegExp(/[^\s/"'\\].*[^\s/"'\\]/g);
live example: http://jsbin.com/irate
var regX = /[^\s/"'\\].*[^\s/"'\\]/g; regX.lastIndex = 0;
live example: http://jsbin.com/irate/2
I'm informed by those who've looked into it more than I have that it's not actually an outright bug, but an ambiguity. And it's not just Chrome, some versions of other browsers have also had a similar problem.
©2020 All rights reserved.