Skip to content

Rewrite old forum links in posts and redirect legacy domain - #5

Merged
fdb merged 1 commit into
mainfrom
claude/project-thread-njwhx1
Oct 16, 2026
Merged

fdb merged 1 commit into
mainfrom
claude/project-thread-njwhx1

Conversation

@fdb

@fdb fdb commented Oct 16, 2026

Copy link
Copy Markdown
Member

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.ts module: Extracts Tender URL parsing logic (tenderDiscussionNumber, tenderCategoryPermalink, isLegacyHost) and adds resolveLegacyPath to look up where old paths live on the forum.

  • Import link rewriting: The importer now rewrites links in post bodies:

    • Bare URLs to old attachments become new file URLs
    • Bare URLs to old discussions become absolute links to new topics (e.g., https://forum.nodebox.net/t/100/slug)
    • Markdown link targets [text](/path) become relative paths
    • Links to moved/renamed discussions are found by discussion number
    • Links to *.tenderapp.com are rewritten (can't be redirected server-side)
    • Links to other hosts are left unchanged
  • Legacy domain middleware: New middleware in app.ts intercepts requests on hosts in LEGACY_HOSTS and redirects them via resolveLegacyPath. Prevents open redirects by concatenating paths rather than resolving with new URL().

  • Configuration: Added LEGACY_HOSTS environment variable (comma-separated) and FORUM_URL for import (defaults to https://forum.nodebox.net).

  • Tests: Added test for link rewriting in posts and legacy domain redirects, including moved discussions and edge cases.

Implementation details

  • Link detection uses a regex that matches absolute URLs and relative paths to old attachments/discussions, then strips trailing punctuation that shouldn't be part of URLs.
  • Discussion lookup is two-stage: exact path first, then by discussion number (handles renames/moves).
  • Category lookup uses slugified permalinks to match imported categories.
  • Bare URLs stay absolute only when they were originally absolute; Markdown link targets become relative paths.

https://claude.ai/code/session_01PrUrXzViMZ25BLZJzy9HfR

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.
@fdb
fdb merged commit 3566a13 into main Oct 16, 2026
1 check passed
@fdb
fdb deleted the claude/project-thread-njwhx1 branch October 16, 2026 19:46
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.

2 participants