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

Change storefrontRedirect to ignore query parameters #1900

Merged
merged 2 commits into from
Mar 26, 2024

Conversation

blittle
Copy link
Contributor

@blittle blittle commented Mar 25, 2024

WHAT is this pull request doing?

Change storefrontRedirect to ignore query parameters when matching redirects. For example, a redirect in the admin from /snowboards to /collections/snowboards will now match on the URL /snowboards?utm_campaign=buffer and redirect the user to /collections/snowboards?utm_campaign=buffer. This is a breaking change. If you want to retain the legacy functionality that is query parameter sensitive, pass matchQueryParams to storefrontRedirect():

storefrontRedirect({
  request,
  response,
  storefront,
  matchQueryParams: true,
});

Without this change, redirects are default broken with any marketing query parameters. For example in Instagram: #1877 (reply in thread)

HOW to test your changes?

  1. Load the demo store URL /collections/hydrogen and make sure that it redirects to /collections/backcountry
  2. Load the demo store URL /collections/hydrogen?someQueryParam=true and make sure that it redirects to /collections/backcountry?someQueryParam=true
  3. Load the demo store URL /collections/hydrogenWithExtraQueryParam and make sure that it redirects to /collections/backcountry?test=true&someQueryParam=true

Post-merge steps

Checklist

  • I've read the Contributing Guidelines
  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've added a changeset if this PR contains user-facing or noteworthy changes
  • I've added tests to cover my changes
  • I've added or updated the documentation

Copy link
Member

@benjaminsehl benjaminsehl left a comment

Choose a reason for hiding this comment

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

Nice one, this looks great to me.

packages/hydrogen/src/routing/redirect.ts Outdated Show resolved Hide resolved
packages/hydrogen/src/routing/redirect.ts Outdated Show resolved Hide resolved
Copy link
Contributor

shopify bot commented Mar 26, 2024

Oxygen deployed a preview of your bl-redirect-query-params branch. Details:

Storefront Status Preview link Deployment details Last update (UTC)
custom-cart-method ✅ Successful (Logs) Preview deployment Inspect deployment March 26, 2024 2:39 PM
vite ✅ Successful (Logs) Preview deployment Inspect deployment March 26, 2024 2:39 PM
subscriptions ✅ Successful (Logs) Preview deployment Inspect deployment March 26, 2024 2:39 PM
skeleton ✅ Successful (Logs) Preview deployment Inspect deployment March 26, 2024 2:39 PM
optimistic-cart-ui ✅ Successful (Logs) Preview deployment Inspect deployment March 26, 2024 2:39 PM
third-party-queries-caching ✅ Successful (Logs) Preview deployment Inspect deployment March 26, 2024 2:39 PM

Learn more about Hydrogen's GitHub integration.

@blittle blittle merged commit 062d6be into main Mar 26, 2024
13 checks passed
@blittle blittle deleted the bl-redirect-query-params branch March 26, 2024 14:52
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.

None yet

3 participants