Optimized parameter extraction so that both the router and state service uses the same regular expression.