ColdBox/coldbox-platform — pull request #172 by bdw429s (2013-12-28 11:37:27+00:00)
Title: Keep optional route order when prepending

When you add a route with optional place holders, multiple routes are added behind the scenes. This is fine unless you set append=false. The additional optional routes are prepended in the wrong order to the beginning of the route array and the most generic route is the only one that ever fires. Here is an example of a route that doesn't register properly:

addRoute(pattern=":foo/:bar?/:doo?", handler="main", action="index", append=false);

The solution I chose was to rework the processRouteOptionals() method to not add the routes right away and build up an array of them instead in the correct order and then add them all at once in the correct order based on the "append" flag.

I also refactored a bit to separate the logic to create and save a route.