crossroads.js
crossroads.js copied to clipboard
[FIX] ISSUE138: S10 shouldn't match S1/:context:
The regex used for OPTIONAL SLASH is too general for some cases like S1/:context:. The slash between '1' and ':' shouldn't be optional because there's no REQUIRED SLASH or QUERY after it.
In the fix, I distinguish between the OPTIONAL SLASH and the conditionally optional slash. Only when the optional slash is before a REQUIRED SLASH or around a QUERY (either optional or required) string or followed by a static slash, it's then optional. Otherwise it's called the conditionally optional. Conditional means that it's required unless it's at the beginning or end of the pattern.
I also added tests to the match spec.
Best regards, Jiawei