Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configured route redirect does not propagate query string #667

Open
rmja opened this issue Oct 20, 2020 · 3 comments
Open

Configured route redirect does not propagate query string #667

rmja opened this issue Oct 20, 2020 · 3 comments

Comments

@rmja
Copy link

rmja commented Oct 20, 2020

I'm submitting a bug report

  • Library Version:
    1.5.0

Please tell us about your environment:

  • Operating System:
    Windows 10

  • Node Version:
    14.6.0

  • NPM Version:
    6.14.8
  • JSPM OR Webpack AND Version
    webpack 4
  • Browser:
    all

  • Language:
    all

Current behavior:
The following route configuration does not propagate the query string to the redirected route:

const routes: RouteConfig[] = [
    { route: "does-not-work", redirect: "/dashboard?autoselect=true"; },
    { route: "does-work", navigationStrategy: instruction => { instruction.config.redirect = "/dashboard"; instruction.queryString = "autoselect=true"; } },
    { route: "dashboard", name: "dashboard", moduleId: PLATFORM.moduleName("./dashboard")  }
];

Expected/desired behavior:

  • What is the expected behavior?
    The route "does-not-work" should have the behavior of "does-work".
    The issue is related to this code:

let queryString = instruction.queryString;
if (queryString) {
redirectLocation += '?' + queryString;
}

I believe the behavior should be more like instruction.queryString || redirectInstruction.queryString

  • What is the motivation / use case for changing the behavior?
    Easier configuration of redirect route
@rmja
Copy link
Author

rmja commented Feb 7, 2022

Is there an update on this? The fix seems really easy.

The error is shown specifically when using aurelia-open-id-connect, where the redirect route is assigned here: https://github.com/aurelia-contrib/aurelia-open-id-connect/blob/master/src/open-id-connect-navigation-strategies.ts#L86. For example:

instruction.config.redirect = "/dashboard?some-parameter=123";

The redirect route may contain query parameters, which are then later stripped by the router during the redirect because of this issue.

To make this work, we either need an update to the router here so that it retains the query parameters (preferred), or an update to aurelia-open-id-connect so that it assigns the query parameters to the instruction in addition to the redirect - this seems wrong.

@rmja
Copy link
Author

rmja commented Feb 7, 2022

It seems that there is a PR for a fix here #643
cc @bigopon

@rmja
Copy link
Author

rmja commented Feb 7, 2022

Related to #639

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant