-
Notifications
You must be signed in to change notification settings - Fork 133
fix: make "Copy for LLMs" button work with query parameters in the URL #2036
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
Conversation
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.
Pull Request Overview
Fixes the "Copy for LLMs" button to correctly handle URLs with query parameters by parsing the URL and appending .md only to the pathname, rather than to the entire URL string which would incorrectly place .md after query parameters.
- Updated
getMarkdownUrlfunction to use URL parsing - Ensures
.mdsuffix is added to pathname only, preserving query parameters
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
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.
This PR is being reviewed by Cursor Bugbot
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
Comment @cursor review or bugbot run to trigger another review on this PR
| const url = new URL(currentUrl); | ||
| url.pathname = `${url.pathname.replace(/\/$/, '')}.md`; | ||
| return url.toString(); | ||
| }; |
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.
Bug: Root Path URL Malformation
The getMarkdownUrl function produces malformed URLs when the currentUrl is a root path (e.g., "https://example.com/"). Removing the trailing slash from a root pathname "/" results in an empty string, leading to an invalid URL like "https://example.com/.md".
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.
Thanks ✅
|
Preview for this PR was built for commit |
Parses the current location as a URL before appending the
.mdsuffix to route to the correctmdURL.E.g. Hubspot adds those tracking query parameters, old code would add the
.mdsuffix to the end of the query params.