nodebb-plugin-markdown 9.0.8 → 9.0.9

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.
Files changed (2) hide show
  1. package/index.js +13 -2
  2. package/package.json +3 -3
package/index.js CHANGED
@@ -23,6 +23,7 @@ let parser;
23
23
  const Markdown = {
24
24
  config: {},
25
25
  _externalImageCache: undefined,
26
+ _externalImageFailures: new Set(),
26
27
  onLoad: async function (params) {
27
28
  const controllers = require('./lib/controllers');
28
29
  const hostMiddleware = require.main.require('./src/middleware');
@@ -209,12 +210,21 @@ const Markdown = {
209
210
  const parsedUrl = url.parse(match);
210
211
  const filename = path.basename(parsedUrl.pathname);
211
212
  const size = Markdown._externalImageCache.get(match);
213
+
214
+ // Short-circuit to ignore previous failures
215
+ const hasFailed = Markdown._externalImageFailures.has(match);
216
+ if (hasFailed) {
217
+ return;
218
+ }
219
+
212
220
  if (size) {
213
221
  env.images.set(filename, size);
214
222
  } else {
215
223
  try {
216
224
  // eslint-disable-next-line no-await-in-loop
217
- const size = await probe(match);
225
+ const size = await probe(match, {
226
+ follow_max: 2,
227
+ });
218
228
 
219
229
  let { width, height } = size;
220
230
 
@@ -226,7 +236,8 @@ const Markdown = {
226
236
  env.images.set(filename, { width, height });
227
237
  Markdown._externalImageCache.set(match, { width, height });
228
238
  } catch (e) {
229
- // No handling required
239
+ // Likely an issue getting the external image size, ignore in the future
240
+ Markdown._externalImageFailures.add(match);
230
241
  }
231
242
  }
232
243
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-markdown",
3
- "version": "9.0.8",
3
+ "version": "9.0.9",
4
4
  "description": "A Markdown parser for NodeBB",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -42,10 +42,10 @@
42
42
  "devDependencies": {
43
43
  "@commitlint/cli": "16.2.1",
44
44
  "@commitlint/config-angular": "16.2.1",
45
- "eslint": "8.9.0",
45
+ "eslint": "8.10.0",
46
46
  "eslint-config-airbnb-base": "15.0.0",
47
47
  "eslint-plugin-import": "2.25.4",
48
48
  "husky": "7.0.4",
49
- "lint-staged": "12.3.4"
49
+ "lint-staged": "12.3.5"
50
50
  }
51
51
  }