question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

trailingSlash: true does not work if there are query params

See original GitHub issue

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?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
ibccommented, Feb 16, 2018

I hope this clearly shows the problem:

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

0reactions
ibccommented, May 6, 2018

Hi, the issue still exists in 6.1.3

Read more comments on GitHub >

github_iconTop Results From Across the Web

Router is not resolving query param without trailing slash
Router is not resolving query param without trailing slash #23706. Open ... I need to use /foo/?myparam=test to make it work ...
Read more >
OK to skip slash before query string? - Stack Overflow
As a matter of modern spec, yes, it is permissible to skip the slash, contrary to what the accepted answer here claims.
Read more >
Location - Angular
Removes a trailing slash from a URL string if needed. Looks for the first occurrence of either # , ? , or the...
Read more >
APPEND_SLASH doesn't work with URLs that have query ...
It is because: request.get_full_path().endswith('/') checks also query string and therefore returns true and the slash is never appended.
Read more >
next/router | Next.js
Therefore, basePath , locale and trailing slash ( trailingSlash: true ) are not included. query : Object - The query string parsed to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found