nomagick commited on
Commit
4bc6394
·
unverified ·
1 Parent(s): 4ab28fe

fix: potential invalid pdf issue

Browse files
Files changed (1) hide show
  1. src/api/crawler.ts +1 -1
src/api/crawler.ts CHANGED
@@ -1005,7 +1005,7 @@ export class CrawlerHost extends RPCHost {
1005
  const pdfUrl = snapshotCopy.pdfs[0];
1006
  if (pdfUrl.startsWith('http')) {
1007
  const sideLoaded = scrappingOptions?.sideLoad?.impersonate[pdfUrl];
1008
- if (sideLoaded?.body) {
1009
  snapshotCopy.pdfs[0] = pathToFileURL(await sideLoaded?.body.filePath).href;
1010
  return this.snapshotFormatter.formatSnapshot(mode, snapshotCopy, nominalUrl, urlValidMs);
1011
  }
 
1005
  const pdfUrl = snapshotCopy.pdfs[0];
1006
  if (pdfUrl.startsWith('http')) {
1007
  const sideLoaded = scrappingOptions?.sideLoad?.impersonate[pdfUrl];
1008
+ if (sideLoaded?.status === 200 && sideLoaded.body) {
1009
  snapshotCopy.pdfs[0] = pathToFileURL(await sideLoaded?.body.filePath).href;
1010
  return this.snapshotFormatter.formatSnapshot(mode, snapshotCopy, nominalUrl, urlValidMs);
1011
  }