fix: base parameter

This commit is contained in:
yanlong.wang 2025-01-16 15:37:16 +08:00
parent 53821d0105
commit e23d9f30a6
No known key found for this signature in database
GPG Key ID: C0A623C0BADF9F37
2 changed files with 6 additions and 4 deletions

View File

@ -832,7 +832,7 @@ export class CrawlerHost extends RPCHost {
nominalUrl?: URL,
urlValidMs?: number
) {
const presumedURL = crawlerOptions.base === 'eventual' ? new URL(snapshot.href) : nominalUrl;
const presumedURL = crawlerOptions.base === 'final' ? new URL(snapshot.href) : nominalUrl;
const respondWith = crawlerOptions.respondWith;
if (respondWith === CONTENT_FORMAT.READER_LM || respondWith === CONTENT_FORMAT.VLM) {

View File

@ -25,7 +25,7 @@ const CONTENT_FORMAT_VALUES = new Set<string>(Object.values(CONTENT_FORMAT));
export const IMAGE_RETENTION_MODES = ['none', 'all', 'alt', 'all_p', 'alt_p'] as const;
const IMAGE_RETENTION_MODE_VALUES = new Set<string>(IMAGE_RETENTION_MODES);
export const BASE_URL_MODES = ['initial', 'eventual'] as const;
export const BASE_URL_MODES = ['initial', 'final'] as const;
const BASE_URL_MODE_VALUES = new Set<string>(BASE_URL_MODES);
class Viewport extends AutoCastable {
@ -199,7 +199,7 @@ class Viewport extends AutoCastable {
schema: { type: 'string' }
},
'X-Base': {
description: 'Select base modes of relative URLs.\n\nSupported: initial, eventual',
description: 'Select base modes of relative URLs.\n\nSupported: initial, final',
in: 'header',
schema: { type: 'string' }
},
@ -490,7 +490,9 @@ export class CrawlerOptions extends AutoCastable {
instance.tokenBudget ??= parseInt(tokenBudget || '') || undefined;
const baseMode = ctx?.req.get('x-base') || undefined;
instance.base ??= baseMode as any;
if (baseMode) {
instance.base = baseMode as any;
}
if (instance.cacheTolerance) {
instance.cacheTolerance = instance.cacheTolerance * 1000;