mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +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 {
|
try {
|
||||||
const { anchor } = args;
|
const { anchor } = args;
|
||||||
let withDomainId = args.domainId || false;
|
const host = this.domain?.host || [];
|
||||||
const domainId = this.args.domainId;
|
const target = args.domainId || this.args.domainId;
|
||||||
const host = this.domain?.host;
|
const rootDomainId = (this.request.host && host?.length && host?.includes(this.request.host))
|
||||||
if (domainId !== 'system' && (
|
? this.args.domainId : 'system';
|
||||||
!this.request.host
|
|
||||||
|| (host instanceof Array
|
|
||||||
? (!host.includes(this.request.host))
|
|
||||||
: this.request.host !== host)
|
|
||||||
)) withDomainId ||= domainId;
|
|
||||||
delete args.query;
|
delete args.query;
|
||||||
res = server.router.url(name, args, { query }).toString();
|
res = server.router.url(name, args, { query }).toString();
|
||||||
if (anchor) res = `${res}#${anchor}`;
|
if (anchor) res = `${res}#${anchor}`;
|
||||||
if (withDomainId) res = `/d/${withDomainId}${res}`;
|
if (target !== rootDomainId) res = `/d/${target}${res}`;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.warn(e.message);
|
logger.warn(e.message);
|
||||||
logger.info('%s %o', name, args);
|
logger.info('%s %o', name, args);
|
||||||
|
|||||||
Reference in new issue
Block a user