-
Notifications
You must be signed in to change notification settings - Fork 66
Preserve live URL query trailing slashes #732
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -104,8 +104,9 @@ function normalizeGitUrl(u: string): string { | |
| } | ||
|
|
||
| function normalizeUrl(u: string): string { | ||
| // For live-site URLs keep query strings and fragments intact; only strip trailing slashes. | ||
| return u.replace(/\/+$/, ''); | ||
| // For live-site URLs keep query strings and fragments intact; only strip | ||
| // trailing slashes from the path segment. | ||
| return u.replace(/\/+(?=[?#]|$)/, ''); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When the URL has no path trailing slash but the query or fragment itself ends with A URL-based approach ( |
||
| } | ||
|
|
||
| function repoNameFromGit(u: string): string | undefined { | ||
|
|
||
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 test suite covers the case where a path trailing slash exists (
/search/,/docs/) before the?or#, but there's no test for the complementary case where there is no path trailing slash yet the query or fragment ends in/— e.g.https://example.com/search?q=/. Under the current implementation that URL normalizes tohttps://example.com/search?q=(trailing slash stripped), which may surprise callers. Adding an assertion for this input would make the boundary of the fix explicit and prevent silent regressions.