mirror of
https://github.com/intergalacticalvariable/reader.git
synced 2024-11-16 11:42:32 +08:00
fix: root content
This commit is contained in:
parent
f1016649ac
commit
39a446f5e7
|
@ -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
|
Loading…
Reference in New Issue
Block a user