mirror of
https://git.mirrors.martin98.com/https://github.com/jina-ai/reader.git
synced 2025-08-19 16:19:06 +08:00
fix: root content
This commit is contained in:
parent
f1016649ac
commit
39a446f5e7
@ -263,6 +263,7 @@ ${this.content}
|
|||||||
tags: ['Crawler'],
|
tags: ['Crawler'],
|
||||||
httpMethod: ['get', 'post'],
|
httpMethod: ['get', 'post'],
|
||||||
returnType: [String, OutputServerEventStream],
|
returnType: [String, OutputServerEventStream],
|
||||||
|
exposeRoot: true,
|
||||||
})
|
})
|
||||||
async crawl(
|
async crawl(
|
||||||
@RPCReflect() rpcReflect: RPCReflection,
|
@RPCReflect() rpcReflect: RPCReflection,
|
||||||
@ -272,21 +273,29 @@ ${this.content}
|
|||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
const noSlashURL = ctx.req.url.slice(1);
|
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;
|
let urlToCrawl;
|
||||||
try {
|
try {
|
||||||
urlToCrawl = new URL(normalizeUrl(noSlashURL.trim(), { stripWWW: false, removeTrailingSlash: false, removeSingleSlash: false }));
|
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) {
|
} catch (err) {
|
||||||
throw new ParamValidationError({
|
throw new ParamValidationError({
|
||||||
message: `${err}`,
|
message: `${err}`,
|
||||||
path: 'url'
|
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 customMode = ctx.req.get('x-respond-with') || 'markdown';
|
||||||
const noCache = Boolean(ctx.req.get('x-no-cache'));
|
const noCache = Boolean(ctx.req.get('x-no-cache'));
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 64157bc57ef9ce2cec69f37b5f55fccb71742b6f
|
Subproject commit 1346b514f3a8d183922bf9257a7f52446a581ac0
|
Loading…
x
Reference in New Issue
Block a user