visionmedia/page.js — pull request #62 by jhnns (2013-06-17 17:32:30+00:00)
Title: Doesn't run on android 2 devices

There are some problems with page.js on android 2's default browser:

The first problem is that on android 2 `typeof /asd/` returns `"function"` instead of `"object"` (thanks android devs). This completely messes up the if-conditions of the page()-function when trying to set a regular expression as path.

The second problem is related to the pathtoRegexp()-function. It seems like android is having problems with the non-greedy `+?`-expression on character classes in combination with `^` at the beginning and `$` at the end. Unfortunately I couldn't find any documentation on this behavior. It can easily be reproduced by comparing `/^[^/]+?$/i.exec("aaa")` in Chrome (matches `"aaa"`) and on Android (doesn't match).

Fortunately these bugs don't require much changes in the code. I've only added an additional check on `arguments.length` and removed the `?` from `+?`. I'm not sure about the latter but afaik the non-greedy option is not required since the regular expression is delimited by `^` and `$` (and thus will always be greedy). The tests are still running but I have to admit that I didn't really understand the pathtoRegexp()-function :smile:

I've read your opinions on legacy browsers and I agree on it regarding polyfills. But in this case I can't do much about it.