core: fix url helper for custom domain#1162
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughRefactors the domain-aware URL prefix logic in packages/hydrooj/src/service/server.ts: it extracts host from this.domain, computes target = args.domainId || this.args.domainId, derives rootDomainId by checking whether this.request.host is present in the domain host list, and only prefixes generated URLs with /d/ when target !== rootDomainId. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 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)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
packages/hydrooj/src/service/server.tsESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/hydrooj/src/service/server.ts (1)
151-153: 💤 Low valueConsider using nullish coalescing for
rootDomainIdfallback.On lines 151-153, if the host match succeeds but
this.args.domainIdhappens to be an empty string (though unlikely),rootDomainIdwould be empty rather than'system'. Using nullish coalescing (??) instead of the ternary could make the fallback behavior more explicit:const rootDomainId = (this.request.host && host && (host instanceof Array ? host.includes(this.request.host) : this.request.host === host) ? this.args.domainId : null) ?? 'system';This ensures
rootDomainIdis always either a valid domain ID or'system', never undefined/null.🤖 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 `@packages/hydrooj/src/service/server.ts` around lines 151 - 153, The current rootDomainId assignment can yield an empty string from this.args.domainId when the host match succeeds; change the expression that computes rootDomainId so the host-match branch returns this.args.domainId or null and then apply nullish coalescing (?? 'system') to provide the fallback. Locate the assignment to rootDomainId (uses this.request.host, host, and this.args.domainId) and rewrite it so the host-match result is combined with ?? 'system' to ensure a non-empty fallback.
🤖 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 `@packages/hydrooj/src/service/server.ts`:
- Around line 151-153: The current rootDomainId assignment can yield an empty
string from this.args.domainId when the host match succeeds; change the
expression that computes rootDomainId so the host-match branch returns
this.args.domainId or null and then apply nullish coalescing (?? 'system') to
provide the fallback. Locate the assignment to rootDomainId (uses
this.request.host, host, and this.args.domainId) and rewrite it so the
host-match result is combined with ?? 'system' to ensure a non-empty fallback.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 11def194-ed74-4bdb-b261-6ab0da707929
📒 Files selected for processing (1)
packages/hydrooj/src/service/server.ts
Summary by CodeRabbit