Invoke router.param() only when route matches

fixes #2206