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(clerk-js): Append initial values query params after hash #1855

Merged
merged 2 commits into from
Oct 17, 2023

Conversation

desiprisg
Copy link
Contributor

@desiprisg desiprisg commented Oct 10, 2023

Description

When calling Clerk.redirectToSignIn/Up(), the initial values query params were being added as normal query params, instead of being appended after the hash. This means that they were not being picked up in a hash routing environment. This PR addresses that issue and appends them the same way as the redirect urls.

Checklist

  • npm test runs as expected.
  • npm run build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Packages affected

  • @clerk/clerk-js
  • @clerk/clerk-react
  • @clerk/nextjs
  • @clerk/remix
  • @clerk/types
  • @clerk/themes
  • @clerk/localizations
  • @clerk/clerk-expo
  • @clerk/backend
  • @clerk/clerk-sdk-node
  • @clerk/shared
  • @clerk/fastify
  • @clerk/chrome-extension
  • gatsby-plugin-clerk
  • build/tooling/chore

@desiprisg desiprisg requested a review from a team as a code owner October 10, 2023 15:37
@changeset-bot
Copy link

changeset-bot bot commented Oct 10, 2023

🦋 Changeset detected

Latest commit: 2d72e68

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

This PR includes changesets to release 3 packages
Name Type
@clerk/clerk-js Patch
@clerk/chrome-extension Patch
@clerk/clerk-expo 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

@desiprisg desiprisg force-pushed the initial_values_query_param_fix branch from 92809b0 to 3f9e29b Compare October 10, 2023 15:38
return this.buildUrlWithAuth(
appendUrlsAsQueryParams(appendAsQueryParams(signInOrUpUrl, options?.initialValues || {}), opts),
);
return this.buildUrlWithAuth(appendAsQueryParams(signInOrUpUrl, { values: options?.initialValues, urls }));
Copy link
Member

Choose a reason for hiding this comment

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

Passing values and urls as separate paramaters here is a bit confusing to me, particularly since they're handled with a single search params abstraction on the other end

Can we strip the origin from urls before calling buildUrlWithAuth, so that we only need to pass in a single object?

Copy link
Contributor Author

@desiprisg desiprisg Oct 11, 2023

Choose a reason for hiding this comment

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

Added a refactor commit.

@LekoArts
Copy link
Member

Please add a description to the PR to describe what you're changing and why. Thanks!

packages/clerk-js/src/core/clerk.ts Show resolved Hide resolved
}
});

return this.buildUrlWithAuth(appendAsQueryParams(signInOrUpUrl, { ...urls, ...options?.initialValues }));
Copy link
Member

Choose a reason for hiding this comment

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

❓Couldn't the stripSameOrigin logic be part of appendAsQueryParams ?

Copy link
Contributor Author

@desiprisg desiprisg Oct 16, 2023

Choose a reason for hiding this comment

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

Wasn't that the case before the refactor @colinclerk proposed? Please look at the first commit and lmk if that's what you mean.

Copy link
Member

Choose a reason for hiding this comment

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

hmm, i see, yeap that covers it.

Copy link
Member

@panteliselef panteliselef left a comment

Choose a reason for hiding this comment

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

After giving another look and your answers to comments this looks ready

@desiprisg desiprisg force-pushed the initial_values_query_param_fix branch from 0e91210 to 7b84319 Compare October 17, 2023 11:24
Copy link
Member

@anagstef anagstef left a comment

Choose a reason for hiding this comment

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

LGTM! 🎉

@desiprisg desiprisg force-pushed the initial_values_query_param_fix branch from a5a4692 to 2d72e68 Compare October 17, 2023 13:13
@desiprisg desiprisg added this pull request to the merge queue Oct 17, 2023
Merged via the queue into main with commit 21f61ce Oct 17, 2023
@desiprisg desiprisg deleted the initial_values_query_param_fix branch October 17, 2023 22:43
@clerk-cookie clerk-cookie mentioned this pull request Oct 17, 2023
@clerk-cookie
Copy link
Collaborator

This PR has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@clerk clerk locked as resolved and limited conversation to collaborators Oct 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants