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(usePathname): prevent duplication of subpath in pathname #1333

Merged
merged 2 commits into from
Dec 17, 2024

Conversation

vgeorge
Copy link
Contributor

@vgeorge vgeorge commented Dec 17, 2024

Related Ticket: #1332

Description of Changes

When using usePathname() hook, strip the application pathname to avoid duplicating it in generated links.

Validation / Testing

App is running from the root path:

  • Make sure PUBLIC_URL is undefined in environment files
  • Start the app with yarn dev, visit http://localhost:9000/data-catalog
  • Clicking on the cards takes to the correct page

Apps is running from a subpath:

Copy link

netlify bot commented Dec 17, 2024

Deploy Preview for veda-ui ready!

Name Link
🔨 Latest commit 5c0bbbb
🔍 Latest deploy log https://app.netlify.com/sites/veda-ui/deploys/6761cd051b120e00089a2853
😎 Deploy Preview https://deploy-preview-1333--veda-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@vgeorge
Copy link
Contributor Author

vgeorge commented Dec 17, 2024

I added a commit now to handle full URLs in PUBLIC_URL environment variable. To test, in addition to the validation scenarios described above, set PUBLIC_URL=http://locahost:9000/subpath and visit the data catalog to test the cards.

@vgeorge vgeorge requested a review from hanbyul-here December 17, 2024 19:21
Copy link
Collaborator

@hanbyul-here hanbyul-here left a comment

Choose a reason for hiding this comment

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

🙇 thanks for looking at it - I do think we need this fix. I also want to add that all the frameworks have a different way of handling this public_url thing (ex.Next uses basePath)

It will be really ideal if we can fully let the router of the application handle this. But we need this fix for now for instance, so I will approve it - but I will think about how we should handle this further.

@vgeorge vgeorge merged commit 9637f97 into main Dec 17, 2024
10 checks passed
@vgeorge vgeorge deleted the fix/use-pathname-duplication branch December 17, 2024 21:54
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.

2 participants