Skip to content

Fix #878 : prevent trailing slashes on absolute Wikipedia URLs #934

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

reshma045
Copy link
Contributor

Summary:
This PR fixes the issue where absolute Wikipedia URLs in the generated reference docs had unwanted trailing slashes.

Closes #878

What was done:

  1. Modified src/scripts/builders/reference.ts to add a check preventing trailing slashes on absolute URLs (URLs starting with http)
  2. Ran npm run build:reference to regenerate the reference documentation files
  3. Verified that Wikipedia links no longer contain trailing slashes and work correctly
  4. Verified that no changes were made to package-lock.json

Thanks to the maintainers for the guidance!

@limzykenneth
Copy link
Member

limzykenneth commented Aug 12, 2025

@reshma045 There are way too many unintended changes here. There should only be changes to src/scripts/builders/reference.ts and the relevant built wikipedia links but it seems all the slashes in the repo has been changed to backslashes here which will likely break a lot of things.

@reshma045 If you need help or more direct guidance please let me know. It's better that you ask us than to continue iterating if you are not sure what the specific changes required are.

Comment on lines +23 to +27
const isAbsoluteUrl = (url: string | undefined): boolean => {
if (!url) return false;
// matches scheme:// or scheme: (mailto:, tel:, etc.) or protocol-relative //example.com
return /^(?:[a-zA-Z][a-zA-Z\d+\-.]*:)?\/\//.test(url) || /^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(url);
};
Copy link
Member

Choose a reason for hiding this comment

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

This check is more complex than it really needs to be. There's no need to cover every possible protocol, possibly just https:// is enough. Also the check for undefined parameter isn't necessary since we don't expect to call this function with no arguments, it probably don't even need to be a function nor use regex I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I will update it correctly.

@blackboxlogic
Copy link

blackboxlogic commented Aug 12, 2025

@reshma045 it looks like you're not reviewing your own changes (packages downgraded on previous PR, slashes here). That would be a good habit to practice before you make a commit and before making a PR.

@reshma045
Copy link
Contributor Author

@reshma045 There are way too many unintended changes here. There should only be changes to src/scripts/builders/reference.ts and the relevant built wikipedia links but it seems all the slashes in the repo has been changed to backslashes here which will likely break a lot of things.

My apologies, but those 1000+ file changes were a result of npm run build:reference. But I'll do my best to learn from this and correct it. Thanks

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.

Links to wikipedia are broken
3 participants