Skip to content

markdown: Resolve . and .. segments in relative URLs - #14516

Open
jakobjung10 wants to merge 1 commit into
rust-lang:mainfrom
jakobjung10:normalize-relative-readme-urls
Open

markdown: Resolve . and .. segments in relative URLs#14516
jakobjung10 wants to merge 1 commit into
rust-lang:mainfrom
jakobjung10:normalize-relative-readme-urls

Conversation

@jakobjung10

Copy link
Copy Markdown

Relative URLs were appended to the README's directory verbatim, so a link like ../img/logo.png in a crate that lives in a subdirectory of its repository produced a raw/HEAD/subdir/../img/logo.png URL that GitHub serves a 404 for. Resolve the segments before building the URL, clamping at the repository root.

SVGs were unaffected because appending the sanitize=true query reparses the URL, which collapses the segments as a side effect.

Closes #5318

Relative URLs were appended to the README's directory verbatim, so a link
like `../img/logo.png` in a crate that lives in a subdirectory of its
repository produced a `raw/HEAD/subdir/../img/logo.png` URL that GitHub
serves a 404 for. Resolve the segments before building the URL, clamping
at the repository root.

SVGs were unaffected because appending the `sanitize=true` query reparses
the URL, which collapses the segments as a side effect.

Closes rust-lang#5318
@jakobjung10
jakobjung10 force-pushed the normalize-relative-readme-urls branch from 42436af to 09550b9 Compare August 25, 2026 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Workspaced crate READMEs do not display relative images correctly

2 participants