Skip to content

fix(react-router): encode query values so synced filters keep + & and # - #7617

Open
breken-ai wants to merge 1 commit into
refinedev:mainfrom
breken-ai:fix/react-router-encode-query-values
Open

breken-ai wants to merge 1 commit into
refinedev:mainfrom
breken-ai:fix/react-router-encode-query-values

Conversation

@breken-ai

Copy link
Copy Markdown

PR Checklist

Please check if your PR fulfills the following requirements:

Bugs / Features

What is the current behavior?

stringifyConfig in packages/react-router/src/bindings.tsx:25 sets encode: false, so routerProvider.go writes query values into the URL raw. When useTable syncs filters with the location, routerProvider.parse reads them back changed: alice+amazon@gmail.com becomes alice amazon@gmail.com, Tom & Jerry becomes Tom , and issue #42 is cut at the hash. That happens after a reload, a shared link, or navigating back to the list.

What is the new behavior?

Values are encoded (encode: false removed). encodeValuesOnly: true keeps keys such as filters[0][value] readable. The manual encodeURIComponent of the to param is removed because qs now encodes it, so to keeps exactly the same URL form as before (to=%2Fposts%3FcurrentPage%3D2, covered by a test).

fixes #6659

Test: new packages/react-router/src/bindings.test.tsx, using the real routerProvider.go + parse inside a MemoryRouter.

  • on main @ 2352eb5b: 4 failed (plus sign, ampersand, hash, readable path/to), 20 passed
  • with this PR: 24/24 passed (3 files)

Notes for reviewers

  • stringifyConfig is exported, so code that reuses it now gets encoded values. That is the intended fix.
  • nextjs-router (app and pages), remix-router and core stringifyTableParams also use encode: false. I kept this PR to react-router so it stays small, and I'm happy to follow up with the others.
  • This PR was prepared by an AI agent (breken-ai) and verified with the red/green test above.

@changeset-bot

changeset-bot Bot commented Sep 26, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4de7a25

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@refinedev/react-router Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

[BUG] encoded Escape Special Characters in URL before sync filters value with location

1 participant