[codex] fix translated internal links#644
Conversation
|
Warning Rate limit exceeded
To continue reviewing without waiting, purchase usage credits in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughIntroduces context-aware URL localization in the translation worker: adds scheme/url helpers and a request-aware ChangesURL Localization Improvements
Sequence Diagram(s)(Skipped — changes are targeted utility and integration updates without a multi-component sequential flow that requires visualization.) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
cc1c34c to
9cd7a51
Compare
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9cd7a51e61
ℹ️ 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".
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/translation-worker/scripts/verify-parser.ts (1)
58-93: ⚡ Quick winAdd an explicit
http://same-site regression case.This block covers
https://and//inputs, but the new logic also has a dedicated same-sitehttp(s)path. Adding onehttp://capgo.app/...assertion would keep that branch from regressing silently.Proposed test addition
<body> <a href="/pricing">Pricing</a> + <a href="http://capgo.app/changelog">Changelog</a> <a href="https://capgo.app/docs/">Docs</a> <a href="//capgo.app/plugins">Plugins</a> <a href="features">Features</a> @@ assert(localizedLinksHtml.includes('hreflang="fr" href="https://capgo.app/fr/blog/post"'), 'Link rewrite changed the French hreflang alternate') assert(localizedLinksHtml.includes('href="/fr/pricing"'), 'Link rewrite did not localize root-relative internal links') +assert(localizedLinksHtml.includes('href="http://capgo.app/fr/changelog"'), 'Link rewrite did not localize absolute same-site http links') assert(localizedLinksHtml.includes('href="https://capgo.app/fr/docs/"'), 'Link rewrite did not localize absolute same-site links') assert(localizedLinksHtml.includes('href="//capgo.app/fr/plugins"'), 'Link rewrite did not localize protocol-relative same-site links')🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/translation-worker/scripts/verify-parser.ts` around lines 58 - 93, Add an explicit HTTP same-site case: include an anchor like <a href="http://capgo.app/docs/">HTTP Docs</a> in the HTML passed to rewriteMetadataAndLinks and add an assertion that localizedLinksHtml.includes('href="http://capgo.app/fr/docs/"') to ensure the http:// same-site branch in rewriteMetadataAndLinks (the function under test) is exercised and does not regress; reference the localizedLinksHtml variable and rewriteMetadataAndLinks call to locate where to add the input and assertion.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@apps/translation-worker/scripts/verify-parser.ts`:
- Around line 58-93: Add an explicit HTTP same-site case: include an anchor like
<a href="http://capgo.app/docs/">HTTP Docs</a> in the HTML passed to
rewriteMetadataAndLinks and add an assertion that
localizedLinksHtml.includes('href="http://capgo.app/fr/docs/"') to ensure the
http:// same-site branch in rewriteMetadataAndLinks (the function under test) is
exercised and does not regress; reference the localizedLinksHtml variable and
rewriteMetadataAndLinks call to locate where to add the input and assertion.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 7cb3642a-80a9-4529-bb57-afa60d89e0bf
📒 Files selected for processing (2)
apps/translation-worker/scripts/verify-parser.tsapps/translation-worker/src/index.ts
|



Summary
Fix translated pages so internal links are rewritten to the active locale path during the translation-worker metadata/link pass.
Root cause
The previous link rewrite only handled root-relative paths like
/pricing. Auto-translated HTML could still keep same-site absolute URLs, protocol-relative URLs, and relative links pointing at the default language route.Changes
hrefandactionvalues across root-relative, relative, protocol-relative, and same-sitehttp(s)forms.Validation
bunx prettier --write apps/translation-worker/src/index.ts apps/translation-worker/scripts/verify-parser.tsbun run ci:verify:translationgit diff --checkSummary by CodeRabbit
New Features
Tests
Chores