mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
core: fix url helper for custom domain (#1162)
Co-authored-by: undefined <i@undefined.moe>
This commit is contained in:
1 parent
879dcffc73
commit
66a8a0ab9e
1 file changed
+5
-10
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user