Repository navigation
Rewrite old forum links in posts and redirect legacy domain - #5
Merged
Merged
Conversation
The importer now rewrites links to old discussions by their discussion number, so moved and renamed discussions resolve, and also rewrites category pages. Bare URLs stay absolute links on the forum, trailing punctuation is kept out of the match, and only links on the old forum's hosts are touched. Once support.nodebox.net is a custom domain of the Worker (LEGACY_HOSTS), every request on it gets a 301 to the same page on the forum, old discussion and category URLs to their new place.
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.
Enables the old Tender forum domain to redirect to the new forum, and rewrites links in imported posts to point to their new locations.
Summary
When the old forum domain (
support.nodebox.net) is pointed at the Worker, all requests now redirect to the same page on the new forum. Old discussion URLs resolve to their topics (even if moved or renamed, via discussion number), category pages to their categories, and other paths to the same location. Additionally, links in post bodies that reference the old forum are rewritten during import to point to new topics, categories, and files.Key changes
New
legacy.tsmodule: Extracts Tender URL parsing logic (tenderDiscussionNumber,tenderCategoryPermalink,isLegacyHost) and addsresolveLegacyPathto look up where old paths live on the forum.Import link rewriting: The importer now rewrites links in post bodies:
https://forum.nodebox.net/t/100/slug)[text](/path)become relative paths*.tenderapp.comare rewritten (can't be redirected server-side)Legacy domain middleware: New middleware in
app.tsintercepts requests on hosts inLEGACY_HOSTSand redirects them viaresolveLegacyPath. Prevents open redirects by concatenating paths rather than resolving withnew URL().Configuration: Added
LEGACY_HOSTSenvironment variable (comma-separated) andFORUM_URLfor import (defaults tohttps://forum.nodebox.net).Tests: Added test for link rewriting in posts and legacy domain redirects, including moved discussions and edge cases.
Implementation details
https://claude.ai/code/session_01PrUrXzViMZ25BLZJzy9HfR