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

Loader and Action params encoding / decoding is faulty #8328

Closed
KingSora opened this issue Dec 18, 2023 · 1 comment
Closed

Loader and Action params encoding / decoding is faulty #8328

KingSora opened this issue Dec 18, 2023 · 1 comment

Comments

@KingSora
Copy link
Contributor

Reproduction

Example: https://stackblitz.com/edit/github-xk9p5y-9ttpl5?file=app%2Froutes%2Findex.tsx

I'm having a loader which receives one parameter called param. This loader is called via a fetcher like:

load(
  `/services/loader/${encodeURIComponent(
    JSON.stringify({ test: 'öpsdgd=$%&!%"&___...Ä+~~' })
  )}`
);

The loader itself returns the params without making any modifications to it:

export const loader = async ({ request, params }: LoaderArgs) => {
  return json(params);
};

Now I would expect that the param field from the loader data is either the string I've passed (the result of whatever encodeURIComponent(JSON.stringify({ test: 'öpsdgd=$%&!%"&___...Ä+~~' })) returns OR a version of that string which has been already decoded with decodeURIComponent.

Instead I'm getting a malformed result which can't be put into the decodeURIComponent because its not a valid URI.

System Info

Shouldn't matter

Used Package Manager

npm

Expected Behavior

A predicatble behavior of the params field in the loader

Actual Behavior

The params field does some kind of transformation with the params which is unexpected.

@brophdawg11
Copy link
Contributor

Duplicate of remix-run/react-router#10814

@brophdawg11 brophdawg11 marked this as a duplicate of remix-run/react-router#10814 Dec 19, 2023
@brophdawg11 brophdawg11 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants