Simplify extractOptionalParameters
Merge pull request #5782 from lucasmichot/4.2-routes-extractoptionalparameters

[4.2] Route : simplify extractOptionalParameters