-
Notifications
You must be signed in to change notification settings - Fork 280
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(remix): Automatically infer path to where component is mounted #3104
fix(remix): Automatically infer path to where component is mounted #3104
Conversation
🦋 Changeset detectedLatest commit: d87a2f0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
!snapshot |
Hey @octoper - 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/backend@1.0.1-snapshot.vc39d42e --save-exact
npm i @clerk/chrome-extension@1.0.1-snapshot.vc39d42e --save-exact
npm i @clerk/clerk-js@5.0.1-snapshot.vc39d42e --save-exact
npm i @clerk/clerk-expo@1.0.1-snapshot.vc39d42e --save-exact
npm i @clerk/fastify@1.0.1-snapshot.vc39d42e --save-exact
npm i gatsby-plugin-clerk@5.0.1-snapshot.vc39d42e --save-exact
npm i @clerk/localizations@2.0.1-snapshot.vc39d42e --save-exact
npm i @clerk/nextjs@5.0.1-snapshot.vc39d42e --save-exact
npm i @clerk/clerk-react@5.0.1-snapshot.vc39d42e --save-exact
npm i @clerk/remix@4.0.1-snapshot.vc39d42e --save-exact
npm i @clerk/clerk-sdk-node@5.0.1-snapshot.vc39d42e --save-exact
npm i @clerk/shared@2.0.1-snapshot.vc39d42e --save-exact
npm i @clerk/themes@2.0.1-snapshot.vc39d42e --save-exact
npm i @clerk/types@4.0.1-snapshot.vc39d42e --save-exact |
e97b394
to
f67ad30
Compare
@octoper what does the |
47c9f5a
to
cec481e
Compare
// Remove the splat route param from the pathname | ||
// so we end up with the pathname where the components are mounted at | ||
// eg /user/123/profile/security will return /user/123/profile as the path | ||
const path = pathname.replace(splatRouteParam, '').replace(/\/$/, '').replace(/^\//, '').trim(); |
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.
Can we add a couple of tests for this? Maybe turn it into a util.
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'm not sure we need to test something here as the test here is going to test if replace
works correctly, the only thing we do here is we are removing a specific part of the pathname, and also remove slashes from the start and the end of the string only if they exist, also we don't have unit tests specifically for Remix right now, and this part is very specific to Remix to make it a general util. The only thing I see here we can extract in a util and test it is the part of removing slashes.
cec481e
to
d87a2f0
Compare
Description
This PR allows to automatically infer the path for where the component is mounted.
This functionality is already introduced for
@clerk/nextjs
(#2634)Checklist
npm test
runs as expected.npm run build
runs as expected.Type of change