@blocklet/crawler 2.1.234 → 2.1.236

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.initSEOMiddleware = void 0;
7
7
  var _utils = require("./utils");
8
- var _stream = require("stream");
9
8
  const initSEOMiddleware = ({
10
9
  autoReturnHtml = true,
11
10
  allowCrawler = true
@@ -29,11 +28,7 @@ const initSEOMiddleware = ({
29
28
  res.setHeader("Last-Modified", req.cachedLastmod);
30
29
  }
31
30
  if (autoReturnHtml && req.cachedHtml) {
32
- const stream = new _stream.Readable();
33
- stream.push(req.cachedHtml);
34
- stream.push(null);
35
- res.set("Content-Type", "text/html, charset=utf-8");
36
- stream.pipe(res);
31
+ res.send(req.cachedHtml);
37
32
  return;
38
33
  }
39
34
  next();
@@ -1,5 +1,4 @@
1
1
  import { isBotUserAgent, getFullUrl, useCache, isAcceptCrawler, isSelfCrawler, getRelativePath } from "./utils.js";
2
- import { Readable } from "stream";
3
2
  export const initSEOMiddleware = ({ autoReturnHtml = true, allowCrawler = true } = {}) => {
4
3
  return async (req, res, next) => {
5
4
  const isBot = isBotUserAgent(req);
@@ -20,11 +19,7 @@ export const initSEOMiddleware = ({ autoReturnHtml = true, allowCrawler = true }
20
19
  res.setHeader("Last-Modified", req.cachedLastmod);
21
20
  }
22
21
  if (autoReturnHtml && req.cachedHtml) {
23
- const stream = new Readable();
24
- stream.push(req.cachedHtml);
25
- stream.push(null);
26
- res.set("Content-Type", "text/html, charset=utf-8");
27
- stream.pipe(res);
22
+ res.send(req.cachedHtml);
28
23
  return;
29
24
  }
30
25
  next();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/crawler",
3
- "version": "2.1.234",
3
+ "version": "2.1.236",
4
4
  "description": "blocklet crawler lib",
5
5
  "publishConfig": {
6
6
  "access": "public"