Skip to content

core: fix url helper for custom domain#1162

Merged
undefined-moe merged 2 commits into
hydro-dev:masterfrom
renbaoshuo:fix/custom-domain-url-builder
May 22, 2026
Merged

core: fix url helper for custom domain#1162
undefined-moe merged 2 commits into
hydro-dev:masterfrom
renbaoshuo:fix/custom-domain-url-builder

Conversation

@renbaoshuo

@renbaoshuo renbaoshuo commented May 14, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Refactor
    • Simplified domain-aware URL prefixing so URLs are only prefixed with a domain segment when the requested target domain differs from the current root domain, reducing incorrect or redundant domain prefixes and improving URL consistency.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 14, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5c6fdd9e-7e4b-45f9-84ff-66eea9e0ea8c

📥 Commits

Reviewing files that changed from the base of the PR and between e121b07 and 6130986.

📒 Files selected for processing (1)
  • packages/hydrooj/src/service/server.ts

Walkthrough

Refactors 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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: fixing the URL helper logic for custom domain handling in the core service.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/hydrooj/src/service/server.ts

ESLint 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/hydrooj/src/service/server.ts (1)

151-153: 💤 Low value

Consider using nullish coalescing for rootDomainId fallback.

On lines 151-153, if the host match succeeds but this.args.domainId happens to be an empty string (though unlikely), rootDomainId would 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 rootDomainId is 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

📥 Commits

Reviewing files that changed from the base of the PR and between 8dc7a73 and e121b07.

📒 Files selected for processing (1)
  • packages/hydrooj/src/service/server.ts

@undefined-moe undefined-moe merged commit 66a8a0a into hydro-dev:master May 22, 2026
6 checks passed
@renbaoshuo renbaoshuo deleted the fix/custom-domain-url-builder branch May 23, 2026 12:26
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