nodebb-plugin-link-preview 1.0.5 → 1.0.7

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/library.js +9 -5
  2. package/package.json +1 -1
package/library.js CHANGED
@@ -1,3 +1,5 @@
1
+ /* eslint-disable no-continue */
2
+
1
3
  'use strict';
2
4
 
3
5
  const winston = require.main.require('winston');
@@ -49,17 +51,19 @@ async function process(content, opts) {
49
51
  for (const anchor of $('a')) {
50
52
  const $anchor = $(anchor);
51
53
  const url = $anchor.attr('href');
54
+ const text = $anchor.text();
52
55
 
53
- if ($anchor.hasClass('plugin-mentions-a')) {
54
- // eslint-disable-next-line no-continue
56
+ if (url !== text) {
55
57
  continue;
56
58
  }
57
59
 
58
60
  const cached = cache.get(`link-preview:${url}`);
59
61
  if (cached) {
60
- // eslint-disable-next-line no-await-in-loop
61
- $anchor.replaceWith($(await render(cached)));
62
- break;
62
+ if (cached.contentType) {
63
+ // eslint-disable-next-line no-await-in-loop
64
+ $anchor.replaceWith($(await render(cached)));
65
+ }
66
+ continue;
63
67
  }
64
68
 
65
69
  // Generate the preview, but return false for now so as to not block response
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-link-preview",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "A starter kit for quickly creating NodeBB plugins",
5
5
  "main": "library.js",
6
6
  "repository": {