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

Relative URL replacement breaks links to directories #94

Open
BobbieGoede opened this issue Jul 16, 2024 · 2 comments · May be fixed by #95
Open

Relative URL replacement breaks links to directories #94

BobbieGoede opened this issue Jul 16, 2024 · 2 comments · May be fixed by #95
Labels
bug Something isn't working

Comments

@BobbieGoede
Copy link

Environment

n/a

Reproduction

See https://unjs.io/packages/magicast, specifically the links to the source code and test cases near the bottom highlighted here. Navigating to these links (https://raw.githubusercontent.com/unjs/magicast/main/src/helpers or https://raw.githubusercontent.com/unjs/magicast/main/test/helpers) will result in a 404 page.

Describe the bug

The original issue was that relative links did not work outside Github, see #24 which was resolved by #52.

The solution was to replace the relative URLs with absolute ones, essentially prefixing with 'https://raw.githubusercontent.com', this works fine for images/assets but does not work for directories. As seen on magicast docs, ./src/helpers is replaced with https://raw.githubusercontent.com/unjs/magicast/main/src/helpers.

Not sure how this can be resolved 🤔 I'm assuming checking each URL for a 404 would be a bit too much. Maybe checking for file extensions? But some file links have no extension like LICENSE.

Additional context

No response

Logs

No response

@BobbieGoede BobbieGoede added the bug Something isn't working label Jul 16, 2024
@pi0
Copy link
Member

pi0 commented Jul 16, 2024

Hey thanks for the detailed issue. I'm little bit occupied to check this more in details, but just a quick idea, maybe wn limit rewrite of #52 to assets(images) which have different markdown?

(also /cc @cpreston321 he might have some idea too)

@BobbieGoede BobbieGoede linked a pull request Jul 16, 2024 that will close this issue
@BobbieGoede
Copy link
Author

Ah I somehow assumed these URLs looked the same 🤦, but of course images use html img tags. This should be resolved by #95, though if there are other types of assets I'm unaware of to take into account, do let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants