nomagick commited on
Commit
39a446f
·
unverified ·
1 Parent(s): f101664

fix: root content

Browse files
backend/functions/src/cloud-functions/crawler.ts CHANGED
@@ -263,6 +263,7 @@ ${this.content}
263
  tags: ['Crawler'],
264
  httpMethod: ['get', 'post'],
265
  returnType: [String, OutputServerEventStream],
 
266
  })
267
  async crawl(
268
  @RPCReflect() rpcReflect: RPCReflection,
@@ -272,21 +273,29 @@ ${this.content}
272
  },
273
  ) {
274
  const noSlashURL = ctx.req.url.slice(1);
 
 
 
 
 
 
 
 
275
  let urlToCrawl;
276
  try {
277
  urlToCrawl = new URL(normalizeUrl(noSlashURL.trim(), { stripWWW: false, removeTrailingSlash: false, removeSingleSlash: false }));
278
- if (urlToCrawl.protocol !== 'http:' && urlToCrawl.protocol !== 'https:') {
279
- throw new ParamValidationError({
280
- message: `Invalid protocol ${urlToCrawl.protocol}`,
281
- path: 'url'
282
- });
283
- }
284
  } catch (err) {
285
  throw new ParamValidationError({
286
  message: `${err}`,
287
  path: 'url'
288
  });
289
  }
 
 
 
 
 
 
290
 
291
  const customMode = ctx.req.get('x-respond-with') || 'markdown';
292
  const noCache = Boolean(ctx.req.get('x-no-cache'));
 
263
  tags: ['Crawler'],
264
  httpMethod: ['get', 'post'],
265
  returnType: [String, OutputServerEventStream],
266
+ exposeRoot: true,
267
  })
268
  async crawl(
269
  @RPCReflect() rpcReflect: RPCReflection,
 
273
  },
274
  ) {
275
  const noSlashURL = ctx.req.url.slice(1);
276
+ if (!noSlashURL) {
277
+ return assignTransferProtocolMeta(`[Usage] https://r.jina.ai/YOUR_URL
278
+ [Homepage] https://jina.ai/reader
279
+ [Source code] https://github.com/jina-ai/reader
280
+ `,
281
+ { contentType: 'text/plain', envelope: null }
282
+ );
283
+ }
284
  let urlToCrawl;
285
  try {
286
  urlToCrawl = new URL(normalizeUrl(noSlashURL.trim(), { stripWWW: false, removeTrailingSlash: false, removeSingleSlash: false }));
 
 
 
 
 
 
287
  } catch (err) {
288
  throw new ParamValidationError({
289
  message: `${err}`,
290
  path: 'url'
291
  });
292
  }
293
+ if (urlToCrawl.protocol !== 'http:' && urlToCrawl.protocol !== 'https:') {
294
+ throw new ParamValidationError({
295
+ message: `Invalid protocol ${urlToCrawl.protocol}`,
296
+ path: 'url'
297
+ });
298
+ }
299
 
300
  const customMode = ctx.req.get('x-respond-with') || 'markdown';
301
  const noCache = Boolean(ctx.req.get('x-no-cache'));
thinapps-shared CHANGED
@@ -1 +1 @@
1
- Subproject commit 64157bc57ef9ce2cec69f37b5f55fccb71742b6f
 
1
+ Subproject commit 1346b514f3a8d183922bf9257a7f52446a581ac0