chore: prefer ctx.URL

This commit is contained in:
yanlong.wang 2025-03-10 15:25:58 +08:00
parent cf01a2c504
commit a9855dcd3b
No known key found for this signature in database
GPG Key ID: C0A623C0BADF9F37

View File

@ -228,9 +228,8 @@ export class CrawlerHost extends RPCHost {
let chargeAmount = 0;
const crawlerOptions = ctx.method === 'GET' ? crawlerOptionsHeaderOnly : crawlerOptionsParamsAllowed;
// ctx.url in Koa is still not a real URL, just the full path including search query.
// ctx.path in Koa does not include the search query.
const targetUrl = await this.getTargetUrl(tryDecodeURIComponent(ctx.url), crawlerOptions);
// Use koa ctx.URL, a standard URL object to avoid node.js framework prop naming confusion
const targetUrl = await this.getTargetUrl(tryDecodeURIComponent(`${ctx.URL.pathname}${ctx.URL.search}`), crawlerOptions);
if (!targetUrl) {
return await this.getIndex(auth);
}