-
Notifications
You must be signed in to change notification settings - Fork 327
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): Respect props passed to buildSignInUrl
and buildSignUpUrl
#3361
fix(clerk-js): Respect props passed to buildSignInUrl
and buildSignUpUrl
#3361
Conversation
🦋 Changeset detectedLatest commit: a4ef2c6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
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 |
@@ -180,25 +203,6 @@ export const stripSameOrigin = (url: URL, baseUrl: URL): string => { | |||
return sameOrigin ? stripOrigin(url) : `${url}`; | |||
}; | |||
|
|||
export const appendAsQueryParams = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Killed this as we no longer need it
dummyUrlForHash.searchParams.append(key, val as string); | ||
} | ||
|
||
// Keep just the pathname and the search | ||
// Merge search params from the hashSearchParams object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All search params appended by clerk-js are snake_cased. Moved the logic here to make sure that the caller has to remember/think about this detail
// Keep just the pathname and the search | ||
// Merge search params from the hashSearchParams object | ||
if (hashSearchParams) { | ||
const paramsArr = Array.isArray(hashSearchParams) ? hashSearchParams : [hashSearchParams]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously, the util supported passing hash params as a string
only but the best way here is to simply pass a URLSearchParams object instead. I added the new functionality but kept the old one, will refactor all usages to the new format in a new PR
return Object.fromEntries( | ||
Object.entries({ ...this.fromSearchParams }).filter(([key]) => RedirectUrls.preserved.includes(key)), | ||
); | ||
} | ||
|
||
#flattenAll() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to stick with a more verbose approach here instead of a a more complex loop of some sort, let me know if you this is is too much
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it
7697adb
to
e607864
Compare
03ee073
to
7cd88d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏
a73f777
to
b73c18e
Compare
buildSignInUrl
and buildSignUpUrl
b73c18e
to
99372db
Compare
!preview |
Hey @desiprisg, your preview is available.
|
!snapshot |
Hey @desiprisg - the snapshot version command generated the following package versions:
Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/chrome-extension@1.0.8-snapshot.v99372db --save-exact
npm i @clerk/clerk-js@5.2.4-snapshot.v99372db --save-exact
npm i @clerk/elements@0.3.4-snapshot.v99372db --save-exact
npm i @clerk/clerk-expo@1.0.8-snapshot.v99372db --save-exact
npm i gatsby-plugin-clerk@5.0.0-beta.45 --save-exact
npm i @clerk/nextjs@5.0.8-snapshot.v99372db --save-exact
npm i @clerk/clerk-react@5.0.5-snapshot.v99372db --save-exact
npm i @clerk/remix@4.0.6-snapshot.v99372db --save-exact |
…Url across navigations
99372db
to
a4ef2c6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but let's state that this won't work with core-2 app and core-1 account portal.
#buildUrl = ( | ||
key: 'signInUrl' | 'signUpUrl', | ||
options: RedirectOptions, | ||
_initValues?: Record<string, string>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙃 The _
prefix in parameters is used to mark unused parameters of a function. Are we sure about this naming?
Description
This PR updates the buildSignInUrl and buildSignUpUrl methods to correctly propagate the redirect props via URL search params. This allows the SignInButton and SignUpButton components to be configurable via their props as well.
Additionally, this PR:
Checklist
npm test
runs as expected.npm run build
runs as expected.Type of change