Skip to content

feat(share): Enhance URL sharing to robustly handle extra URL parameters - #636

Open
TKanX wants to merge 4 commits into
hackclub:mainfrom
TKanX:main
Open

feat(share): Enhance URL sharing to robustly handle extra URL parameters#636
TKanX wants to merge 4 commits into
hackclub:mainfrom
TKanX:main

Conversation

@TKanX

@TKanX TKanX commented Apr 9, 2025

Copy link
Copy Markdown
Member

Summary:

Enhances the URL sharing functionality to be more robust in handling URLs that contain extra query parameters beyond the intended shared data. Previously, the URL parsing was sensitive to additional parameters, leading to errors when URLs were augmented by external services (like ChatGPT) with tracking flags or other parameters. This enhancement introduces a more resilient URL parsing mechanism that specifically extracts the shared data parameter while gracefully ignoring any extraneous parameters.

Related Issues:

Changes:

  • Improved getUrlData function:
    • Enhanced the getUrlData function to utilize url.searchParams.get('data') instead of url.search.slice(1) for retrieving compressed data from the URL.
    • This improvement ensures that the function now specifically targets and extracts the data parameter, effectively disregarding any other parameters that might be present in the URL's query string.
  • Maintained onShareButtonClicked function:
    • The onShareButtonClicked function remains updated to construct share URLs with a dedicated data parameter using template literals: ${location.origin}?data=${compressed}.
    • This maintains a clear and consistent structure for generated share URLs, ensuring the shared data is predictably located within the data parameter.

@vercel

vercel Bot commented Apr 9, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
sinerider ✅ Ready (Inspect) Visit Preview Apr 9, 2025 5:32am

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.

1 participant