router5: trailingSlash: true does not work if there are query params

I’m having many issues with router5 when I use URLs with “query” parameters (not real URL query params, but those params after “?” after the URL fragment “#”).

My routes:

{
  name : "foo",
  path  : "/:companyId"
}

Router options:

{
  trailingSlash : true,
  strictQueryParams : false
}

Then let’s open the web app directly with the following URLs:

https://localhost/#/microsoft

  • It matches the foo route.

https://localhost/#/microsoft/

  • It matches the foo route and rewrites the URL to https://localhost/#/microsoft.

https://localhost/#/microsoft?qwe=123

  • It matches the foo route.

https://localhost/#/microsoft/?qwe=123

  • It does NOT match the foo route.

I’ve also tried adding “/” to the path in the foo route and also trailingSlash:false. Nothing works.

Do I miss something? or is it just that router5 does not properly behave when there are “extra query params” in the initial URL?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 23 (7 by maintainers)

Most upvoted comments

I hope this clearly shows the problem:

https://github.com/ibc/router5-url-issue