improve route matching regex and fix bug in transitional routes with a query params