nodebb-plugin-mentions 4.8.9 → 4.8.11

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-mentions",
3
- "version": "4.8.9",
3
+ "version": "4.8.11",
4
4
  "description": "NodeBB Plugin that allows users to mention other users by prepending an '@' sign to their username",
5
5
  "main": "library.js",
6
6
  "repository": {
@@ -30,8 +30,8 @@
30
30
  "validator": "^13.0.0"
31
31
  },
32
32
  "devDependencies": {
33
- "eslint": "^9.25.1",
34
- "eslint-config-nodebb": "^1.1.4",
33
+ "eslint": "^10.0.0",
34
+ "eslint-config-nodebb": "^2.0.0",
35
35
  "eslint-plugin-import": "^2.31.0",
36
36
  "mocha": "11.7.5"
37
37
  }
package/test/index.js CHANGED
@@ -38,7 +38,7 @@ describe('regex', () => {
38
38
  it('should match a mention in all test strings', () => {
39
39
  const matches = string.match(matcher);
40
40
  assert(matches, `@testUser was not found in this string: ${string}`);
41
- assert.equal(slugify(matches[0]), 'testuser');
41
+ assert(['@testuser', '@testuser.'].includes(slugify(matches[0])));
42
42
  });
43
43
  });
44
44
 
@@ -163,7 +163,7 @@ describe('parser', () => {
163
163
  beforeEach(async () => {
164
164
  slug = utils.generateUUID().slice(0, 10);
165
165
  uid = await user.create({ username: slug });
166
- emailUid = await user.create({ username: `${slug}@test.nodebb.org` });
166
+ // emailUid = await user.create({ username: `${slug}@test.nodebb.org` });
167
167
  });
168
168
 
169
169
  it('should properly parse both users even if one user\'s username is a subset of the other', async () => {
@@ -172,7 +172,7 @@ describe('parser', () => {
172
172
 
173
173
  const html = await main.parseRaw(md);
174
174
 
175
- assert.strictEqual(html, `This sentence contains two mentions: <a class="plugin-mentions-user plugin-mentions-a" href="http://127.0.0.1:4567/uid/1">@${slug}</a> and <a class="plugin-mentions-user plugin-mentions-a" href="http://127.0.0.1:4567/uid/2">@${slug}-two</a>`);
175
+ assert.strictEqual(html, `This sentence contains two mentions: <a class="plugin-mentions-user plugin-mentions-a" href="/user/${slug}" aria-label="Profile: ${slug}">@<bdi>${slug}</bdi></a> and <a class="plugin-mentions-user plugin-mentions-a" href="/user/${slug}-two" aria-label="Profile: ${slug}-two">@<bdi>${slug}-two</bdi></a>`);
176
176
  });
177
177
 
178
178
  strings.forEach((string) => {
@@ -180,8 +180,9 @@ describe('parser', () => {
180
180
  const index = string.indexOf('@testUser');
181
181
  let check = string;
182
182
  if (!index || string[index - 1] !== '>') {
183
- check = string.replace(/@testUser/g, `<a class="plugin-mentions-user plugin-mentions-a" href="http://127.0.0.1:4567/uid/${uid}">@${slug}</a>`);
184
- string = string.replace(/testUser/g, slug);
183
+ check = string.replace(/@testUser\.?/g, `<a class="plugin-mentions-user plugin-mentions-a" href="/user/${slug}" aria-label="Profile: ${slug}">@<bdi>${slug}</bdi></a>`);
184
+ // check = string.replace(/@testUser/g, `<a class="plugin-mentions-user plugin-mentions-a" href="http://127.0.0.1:4567/uid/${uid}">@${slug}</a>`);
185
+ string = string.replace(/testUser\.?/g, slug);
185
186
  }
186
187
  const html = await main.parseRaw(string);
187
188
 
@@ -205,3 +206,15 @@ describe('parser', () => {
205
206
  });
206
207
  });
207
208
  });
209
+
210
+ describe('.getMatches() edge cases', () => {
211
+ before(async function () {
212
+ this.slug = slugify(utils.generateUUID().slice(0, 8));
213
+ this.uid = await user.create({ username: this.slug });
214
+ });
215
+
216
+ it('should match a mention at the end of a sentence', async function () {
217
+ const matches = await main.getMatches(`test sentence @${this.slug}.`);
218
+ console.log(matches);
219
+ });
220
+ });