Fix legacy forum links after .uk migration - #71
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideUpdates legacy forum link rewriting so both historical xmoj-bbs.tech and xmoj-bbs.me domains are rewritten to xmoj-script.uk (including subdomains), and extends the GetPost test to cover the new behavior and multiple domains/subdomains. Flow diagram for legacy forum link rewritingflowchart LR
A[GetPost reads forum replies] --> B[Process reply content]
B --> C{Contains xmoj-bbs.tech or xmoj-bbs.me}
C -->|yes| D[Replace domain with xmoj-script.uk]
C -->|no| E[Keep content unchanged]
D --> F[Return replies with preserved subdomains]
E --> F
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="Source/Process.ts" line_range="885" />
<code_context>
}
let processedContent: string = ReplyItem["content"];
- processedContent = processedContent.replace(/xmoj-bbs\.tech/g, "xmoj-bbs.me");
+ processedContent = processedContent.replace(/xmoj-bbs\.(?:tech|me)/g, "xmoj-script.uk");
ResponseData.Reply.push({
ReplyID: ReplyItem["reply_id"],
</code_context>
<issue_to_address>
**issue (bug_risk):** The unbounded, case-sensitive replacement rewrites any text containing `xmoj-bbs.tech` or `xmoj-bbs.me`, including unrelated hostnames such as `xmoj-bbs.me.example.com` and uppercase forms of the domain, producing incorrect or still-invalid links.
**Triggers:** When a reply contains a hostname that merely contains a legacy domain string or uses uppercase characters.
**Suggested fix:** Match the domain as a case-insensitive hostname with URL boundary checks, so only the exact legacy host and its subdomains are rewritten.
```suggestion
processedContent = processedContent.replace(/(^|[^\w-])xmoj-bbs\.(?:tech|me)(?![\w.-])/gi, "$1xmoj-script.uk");
```
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: Source/Process.ts:885
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| } | ||
| let processedContent: string = ReplyItem["content"]; | ||
| processedContent = processedContent.replace(/xmoj-bbs\.tech/g, "xmoj-bbs.me"); | ||
| processedContent = processedContent.replace(/xmoj-bbs\.(?:tech|me)/g, "xmoj-script.uk"); |
There was a problem hiding this comment.
issue (bug_risk): The unbounded, case-sensitive replacement rewrites any text containing xmoj-bbs.tech or xmoj-bbs.me, including unrelated hostnames such as xmoj-bbs.me.example.com and uppercase forms of the domain, producing incorrect or still-invalid links.
Triggers: When a reply contains a hostname that merely contains a legacy domain string or uses uppercase characters.
Suggested fix: Match the domain as a case-insensitive hostname with URL boundary checks, so only the exact legacy host and its subdomains are rewritten.
| processedContent = processedContent.replace(/xmoj-bbs\.(?:tech|me)/g, "xmoj-script.uk"); | |
| processedContent = processedContent.replace(/(^|[^\w-])xmoj-bbs\.(?:tech|me)(?![\w.-])/gi, "$1xmoj-script.uk"); |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b36c15f2a9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
| let processedContent: string = ReplyItem["content"]; | ||
| processedContent = processedContent.replace(/xmoj-bbs\.tech/g, "xmoj-bbs.me"); | ||
| processedContent = processedContent.replace(/xmoj-bbs\.(?:tech|me)/g, "xmoj-script.uk"); |
There was a problem hiding this comment.
Add a boundary after the legacy TLD
Because the new me alternative has no trailing domain boundary, reading a post now corrupts any content whose hostname merely starts with that text. For example, https://xmoj-bbs.media/post becomes https://xmoj-script.ukdia/post, and https://xmoj-bbs.me.evil.test/ is rewritten despite not being on the legacy domain. Restrict the match to a complete hostname suffix before replacing it.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
1 issue found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="Source/Process.ts">
<violation number="1" location="Source/Process.ts:885">
P3: The rewrite regex /xmoj-bbs\.(?:tech|me)/g has no trailing word boundary, so it matches the prefix of any token that merely begins with the legacy host text. 'xmoj-bbs.member' becomes 'xmoj-script.ukmber' and 'xmoj-bbs.meeting' becomes 'xmoj-script.uketing'. Add \b after the TLD alternation so only the full hostname is rewritten; subdomain preservation (www./assets.) is unaffected because the boundary sits after the replaced TLD.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| } | ||
| let processedContent: string = ReplyItem["content"]; | ||
| processedContent = processedContent.replace(/xmoj-bbs\.tech/g, "xmoj-bbs.me"); | ||
| processedContent = processedContent.replace(/xmoj-bbs\.(?:tech|me)/g, "xmoj-script.uk"); |
There was a problem hiding this comment.
P3: The rewrite regex /xmoj-bbs.(?:tech|me)/g has no trailing word boundary, so it matches the prefix of any token that merely begins with the legacy host text. 'xmoj-bbs.member' becomes 'xmoj-script.ukmber' and 'xmoj-bbs.meeting' becomes 'xmoj-script.uketing'. Add \b after the TLD alternation so only the full hostname is rewritten; subdomain preservation (www./assets.) is unaffected because the boundary sits after the replaced TLD.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At Source/Process.ts, line 885:
<comment>The rewrite regex /xmoj-bbs\.(?:tech|me)/g has no trailing word boundary, so it matches the prefix of any token that merely begins with the legacy host text. 'xmoj-bbs.member' becomes 'xmoj-script.ukmber' and 'xmoj-bbs.meeting' becomes 'xmoj-script.uketing'. Add \b after the TLD alternation so only the full hostname is rewritten; subdomain preservation (www./assets.) is unaffected because the boundary sits after the replaced TLD.</comment>
<file context>
@@ -882,7 +882,7 @@ export class Process {
}
let processedContent: string = ReplyItem["content"];
- processedContent = processedContent.replace(/xmoj-bbs\.tech/g, "xmoj-bbs.me");
+ processedContent = processedContent.replace(/xmoj-bbs\.(?:tech|me)/g, "xmoj-script.uk");
ResponseData.Reply.push({
ReplyID: ReplyItem["reply_id"],
</file context>
| processedContent = processedContent.replace(/xmoj-bbs\.(?:tech|me)/g, "xmoj-script.uk"); | |
| processedContent = processedContent.replace(/xmoj-bbs\.(?:tech|me)\b/g, "xmoj-script.uk"); |
Summary
xmoj-bbs.techandxmoj-bbs.medomains toxmoj-script.ukwhen forum posts are readwwwandassetsVerification
git diff --checknode --check test/process.test.jsThe full npm suite could not be run locally because this checkout did not have dependencies installed; repository CI should run it.
Summary by Sourcery
Update forum reply link rewriting for the .uk domain migration while preserving legacy subdomains.
Bug Fixes:
Tests:
Summary by cubic
Rewrite legacy forum links in reply content from xmoj-bbs.tech and xmoj-bbs.me to xmoj-script.uk, preserving subdomains like www and assets. This aligns replies with the .uk migration and prevents broken links.
Review notes
Written for commit b36c15f. Summary will update on new commits.