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

fix(gatsby): fix issue with decoding URl #34816

Merged
merged 10 commits into from
Mar 8, 2022
Merged

Conversation

marvinjude
Copy link
Contributor

@marvinjude marvinjude commented Feb 15, 2022

Description

Using a percent encoded character like %25 in URL breaks due to multiple decodeURIComponent calls. This PR address this issue by making sure the query string part of the URL is always encoded.

Related Issues

Fixes #34797
Fixes #34998

[sc-46573]

@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Feb 15, 2022
@marvinjude marvinjude changed the title fix issue with decoding URl fix(gatsby): fix issue with decoding URl Feb 15, 2022
@marvinjude marvinjude marked this pull request as draft February 15, 2022 11:59
@Abhirup-99

This comment was marked as spam.

@LekoArts LekoArts added topic: core Relates to Gatsby's core (e.g. page loading, reporter, state machine) and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Mar 7, 2022
@marvinjude marvinjude marked this pull request as ready for review March 7, 2022 11:54
@wardpeet
Copy link
Contributor

wardpeet commented Mar 7, 2022

To make sure do we have tests around query-strings without escaping and paths without escaping. Just making sure that we didn't miss any use case

@pieh
Copy link
Contributor

pieh commented Mar 7, 2022

To make sure do we have tests around query-strings without escaping and paths without escaping. Just making sure that we didn't miss any use case

@wardpeet We have quite a bit of e2e tests using regular query params. Some of them added for trailing slashes like

describe(`Keeps search query`, () => {
describe(`No trailing slash canonical path (/slashes/no-trailing)`, () => {
it(`/slashes/no-trailing?param=value`, () => {
cy.visit(`/slashes/no-trailing?param=value`).waitForRouteChange()
cy.getTestElement(`search-marker`)
.invoke(`text`)
.should(`equal`, `?param=value`)
cy.location(`pathname`).should(`equal`, `/slashes/no-trailing`)
cy.location(`search`).should(`equal`, `?param=value`)
})

So we should be set for baseline testing and would need just add cases for specifically encoded ones which for now was added for e2e/dev-runtime (we should add same ones to e2e/prod-runtime as well to be sure)

@marvinjude
Copy link
Contributor Author

We also have some here

it(`should support search parameter with Link component`, () => {
cy.visit(`/`, {
failOnStatusCode: false,
}).waitForRouteChange()
cy.getTestElement(`redirect-two-search`).click().waitForRouteChange()
cy.location(`pathname`).should(`equal`, `/redirect-search-hash`)
cy.location(`hash`).should(`equal`, ``)
cy.location(`search`).should(`equal`, `?query_param=hello`)
})
it(`should support search parameter on direct visit`, () => {
cy.visit(`/redirect-two?query_param=hello`, {
failOnStatusCode: false,
}).waitForRouteChange()
cy.location(`pathname`).should(`equal`, `/redirect-search-hash`)
cy.location(`hash`).should(`equal`, ``)
cy.location(`search`).should(`equal`, `?query_param=hello`)
})

@Abhirup-99
Copy link

Abhirup-99 commented Mar 8, 2022

Thanks for the PR and the approval. Do push a release with the changes as we are eagerly waiting for this :).

@wardpeet wardpeet merged commit 93fd124 into master Mar 8, 2022
@wardpeet wardpeet deleted the juag/fix-decode-uri-issue branch March 8, 2022 13:41
@marvinjude
Copy link
Contributor Author

marvinjude commented Mar 8, 2022

Hi @Abhirup-99,

You can test this out in gatsby@next - yarn add gatsby@next.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: core Relates to Gatsby's core (e.g. page loading, reporter, state machine)
Projects
None yet
5 participants