fix: root content

This commit is contained in:
yanlong.wang 2024-04-25 15:43:17 +08:00
parent f1016649ac
commit 39a446f5e7
No known key found for this signature in database
GPG Key ID: C0A623C0BADF9F37
2 changed files with 16 additions and 7 deletions

View File

@ -263,6 +263,7 @@ ${this.content}
tags: ['Crawler'],
httpMethod: ['get', 'post'],
returnType: [String, OutputServerEventStream],
exposeRoot: true,
})
async crawl(
@RPCReflect() rpcReflect: RPCReflection,
@ -272,21 +273,29 @@ ${this.content}
},
) {
const noSlashURL = ctx.req.url.slice(1);
if (!noSlashURL) {
return assignTransferProtocolMeta(`[Usage] https://r.jina.ai/YOUR_URL
[Homepage] https://jina.ai/reader
[Source code] https://github.com/jina-ai/reader
`,
{ contentType: 'text/plain', envelope: null }
);
}
let urlToCrawl;
try {
urlToCrawl = new URL(normalizeUrl(noSlashURL.trim(), { stripWWW: false, removeTrailingSlash: false, removeSingleSlash: false }));
if (urlToCrawl.protocol !== 'http:' && urlToCrawl.protocol !== 'https:') {
throw new ParamValidationError({
message: `Invalid protocol ${urlToCrawl.protocol}`,
path: 'url'
});
}
} catch (err) {
throw new ParamValidationError({
message: `${err}`,
path: 'url'
});
}
if (urlToCrawl.protocol !== 'http:' && urlToCrawl.protocol !== 'https:') {
throw new ParamValidationError({
message: `Invalid protocol ${urlToCrawl.protocol}`,
path: 'url'
});
}
const customMode = ctx.req.get('x-respond-with') || 'markdown';
const noCache = Boolean(ctx.req.get('x-no-cache'));

@ -1 +1 @@
Subproject commit 64157bc57ef9ce2cec69f37b5f55fccb71742b6f
Subproject commit 1346b514f3a8d183922bf9257a7f52446a581ac0