Skip to content

Query parameters get destroyed by being decoded twice #78

@perbergland

Description

@perbergland

The use case is for a roundtrip to a login page that then is supposed to take you back to the original page including its query parameters.

You will then have a returnUrl query parameter which has doubly-encoded query parameters which are not handled properly because flow-router seems to decode the query parameters twice when it is vital that they are only decoded once.

Example:

Original url:
http://localhost:3000/projects?param1=abc&redirectUrl=https%3A%2F%2Fwww.company.com%2Fabc123

Redirected to
http://localhost:3000/login?returnUrl=%2Fprojects%3Fparam1%3Dabc%26redirectUrl%3Dhttps%253A%252F%252Fwww.company.com%252Fabc123

The queryParams provided by FlowRouter to the route registered for /login will now be
{returnUrl: "/projects?param1=abc", redirectUrl: "https://www.company.com/abc123"}

i.e. the entire redirectUrl part of the returnUrl is lost.

The hack fix is to use qs directly instead of the queryParam provided by FlowRouter

qs.parse(window.location.search, {
ignoreQueryPrefix: true,
});

which gives the correct result:

{returnUrl: "/projects?param1=abc&redirectUrl=https%3A%2F%2Fwww.company.com%2Fabc123"}

This happens when using kadira:flowrouter and [email protected], regardless of using the latest qs version (6.9.3) or some earlier version like 6.5.1.

This is for Meteor 1.10.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions