Review 9.5 Merged

65041[BUGFIX] Adjust processing order of routes during URL generation

Oliver Hader CR +2 V +2 Hard +541 −13 updated 07/25/20, 09:27

Commit message

Prior to this patch routes were processed in reverse definition order.
Routes defined last came first. Depending on the existence of variable
defaults this behavior produced a couple of unexpected results.

  first:
    routePath: '/route/{a}/{b}'
  second:
    routePath: '/route/{c}'
    defaults:
      c: '0'

The example above, processed in reverse order and having parameters
`a` and `b` given, still resulted in `second` route being used since
the missing parameter `c` was defined by corresponding variable default.

This change adjusts the order of routes depending on given parameters,
completeness of a route (when all parameters are given, even defaults).
Sorting is adjusted based on the following criteria:

* default routes (e.g. `/my-page`) - processed later
* static routes (e.g. `/my-page/list`) - processed later
* all variables are given (complete) - processed earlier
  (e.g. parameters `a` and `b` are given for route `/route/{a}/{b}`)
* all mandatory variables are given (complete) - processed earlier
* less missing variable defaults - processed earlier
* less variable defaults amount - processed earlier

Tests in class `RouteSorterTest` provide more examples & details.

Review

  • Code review CR +2

    Imported before Forger kept the single votes, the next import adds them.

  • Verified V +2

    Imported before Forger kept the single votes, the next import adds them.

Issues 1

Files 6