Redirect / to the main page instead of serving it in place#27
Merged
Conversation
The served main page broke its own CSS and images when the entry point was a nested page. kage saves each page's asset links as mirror-relative paths (../_kage/...) computed for that page's own location, but the handler served the main page's bytes directly at /, so the browser resolved those relative URLs against / and 404ed every one of them. A developer.apple.com/documentation mirror landed at / with no styles. Redirect / to the main page's canonical content path, the way the archive's W/mainPage redirect already does, so the browser navigates to the page's real URL and resolves its relative assets correctly. Kiwix was unaffected because it follows that redirect itself.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A served mirror whose entry point is a nested page lost all its CSS and images when opened at the root.
kage saves each page's asset links as mirror-relative paths (
../_kage/...) computed for that page's own location. The serve handler answered/with the main page's bytes directly, so the browser resolved those relative URLs against/and 404ed every one. Adeveloper.apple.com/documentationmirror, whose main page isdeveloper.apple.com/documentation/index.html, landed at/completely unstyled.Redirect
/to the main page's canonical content path instead, the way the archive'sW/mainPageredirect already does, so the browser navigates to the page's real URL and resolves its relative assets correctly. Kiwix was unaffected because it follows that redirect itself.Verified on a real apple-docs ZIM:
/now 302s to/developer.apple.com/documentation/index.htmland the page's../_kage/...stylesheets load 200.