Skip to content

fix: preserve query parameters containing additional question marks in fromParameters - #495

Closed
abdul-karim-mia wants to merge 1 commit into
fastify:mainfrom
abdul-karim-mia:fix/from-parameters-query-split
Closed

abdul-karim-mia wants to merge 1 commit into
fastify:mainfrom
abdul-karim-mia:fix/from-parameters-query-split

Conversation

@abdul-karim-mia

Copy link
Copy Markdown

Fixes #491.

In \extractUrlComponents(), the URL was previously split using \urlString.split('?', 2). In JavaScript, providing a limit to \String.prototype.split\ drops all remaining elements instead of grouping them into the last element. Consequently, when a query string contains additional literal ?\ characters (such as redirect or continuation parameters like ?next=/a?b=1&c=2, which are valid under RFC 3986 section 3.4), any characters and subsequent query parameters after the second ?\ were discarded.

This change:

  1. Locates the first ?\ via \urlString.indexOf('?')\ and slices the path and full \queryString\ accordingly.
  2. Adds a regression test verifying that query parameters containing additional ?\ characters are preserved through
    eply.fromParameters().

All existing and new tests pass with 100% test and branch coverage, clean lint, and clean type tests.

…n fromParameters

Signed-off-by: Abdul karim mia <97598943+abdul-karim-mia@users.noreply.github.com>
@SameRainbows

This comment was marked as spam.

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina

Copy link
Copy Markdown
Member

CI is red

@Tony133

Tony133 commented Nov 14, 2026

Copy link
Copy Markdown
Member

Thanks for the contribution! The issue has been fixed by #492, which was opened earlier with the same change, and released in v11.6.8, so I'm closing this one.

@Tony133 Tony133 closed this Nov 14, 2026
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.

reply.fromParameters() drops query params after a second "?"

4 participants