core: fix url helper for custom domain (#1162)

Co-authored-by: undefined <i@undefined.moe>
This commit is contained in:
Baoshuoandundefined authored and GitHub committed 2026-05-22 11:03:32 +08:00
1 parent 879dcffc73
commit 66a8a0ab9e
1 file changed
+5 -10
+5 -10
View File
@@ -144,19 +144,14 @@ export async function apply(ctx: Context) {
}
try {
const { anchor } = args;
let withDomainId = args.domainId || false;
const domainId = this.args.domainId;
const host = this.domain?.host;
if (domainId !== 'system' && (
!this.request.host
|| (host instanceof Array
? (!host.includes(this.request.host))
: this.request.host !== host)
)) withDomainId ||= domainId;
const host = this.domain?.host || [];
const target = args.domainId || this.args.domainId;
const rootDomainId = (this.request.host && host?.length && host?.includes(this.request.host))
? this.args.domainId : 'system';
delete args.query;
res = server.router.url(name, args, { query }).toString();
if (anchor) res = `${res}#${anchor}`;
if (withDomainId) res = `/d/${withDomainId}${res}`;
if (target !== rootDomainId) res = `/d/${target}${res}`;
} catch (e) {
logger.warn(e.message);
logger.info('%s %o', name, args);