quirkey/sammy

Include original route path pattern in EventContext

Opened this issue · 0 comments

Currently, EvenContext has a path field. This field is the triggered uri, there is no way of finding out which route path pattern was called.

I can always use app.lookupRoute but this gives me a handle on the resulting regex of the declared route. There are cases where I need to index a dictionary using the declared route path patterns and match against them using the info in the EventContext. Having to convert the paths to their regex equivalent is combersome, hard to read and inconsistent if :<param_nam> tokens are used initially.

Eg: #/users/:username/controllers has to be read as /#\/users\/([^\/]+)\/controllers$/

Also the lookupRoute and contextMatchesOptions functions seem to ignore the format :<param_name>. It should do a path.replace(PATH_NAME_MATCHER, PATH_REPLACER)