mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-07 09:56:16 +02:00
fix: #14147, dont create wrong backlinks
syncBacklinks expects raw post content, html was passed to it from onNewPost since it was switched to use getPostSummary
backlinkRegex was matching ${nconf.get('url')}/topic/1aef954c-d0dc-45cf-acf2-e3a59f6cc134/foo and return tid=1 instead of the uuid
remove useless if check in syncBacklinks
fixed parseInts on tids
current - remove are both arrays use .length
This commit is contained in:
@@ -1152,12 +1152,10 @@ describe('Post\'s', () => {
|
||||
|
||||
describe('.syncBacklinks()', () => {
|
||||
it('should error on invalid data', async () => {
|
||||
try {
|
||||
await topics.syncBacklinks();
|
||||
} catch (e) {
|
||||
assert(e);
|
||||
assert.strictEqual(e.message, '[[error:invalid-data]]');
|
||||
}
|
||||
await assert.rejects(
|
||||
topics.syncBacklinks(),
|
||||
{ message: '[[error:invalid-data]]' },
|
||||
);
|
||||
});
|
||||
|
||||
it('should do nothing if the post does not contain a link to a topic', async () => {
|
||||
@@ -1192,9 +1190,7 @@ describe('Post\'s', () => {
|
||||
const backlinks = await db.getSortedSetMembers('pid:2:backlinks');
|
||||
|
||||
assert.strictEqual(count, 0);
|
||||
assert(events);
|
||||
assert.strictEqual(events.length, 1);
|
||||
assert(backlinks);
|
||||
assert.strictEqual(backlinks.length, 0);
|
||||
});
|
||||
|
||||
@@ -1219,6 +1215,17 @@ describe('Post\'s', () => {
|
||||
assert(backlinks);
|
||||
assert.strictEqual(backlinks.length, 0);
|
||||
});
|
||||
|
||||
it('should not create a wrong backlink to topic/1 with AP topic url', async () => {
|
||||
const { postData } = await topics.post({
|
||||
uid: 1,
|
||||
cid,
|
||||
title: 'Topic backlink testing - topic 2',
|
||||
content: `testing ${nconf.get('url')}/topic/1aef954c-d0dc-45cf-acf2-e3a59f6cc134/foo`,
|
||||
});
|
||||
const backlinks = await db.getSortedSetMembers(`pid:${postData.pid}:backlinks`);
|
||||
assert.strictEqual(backlinks.length, 0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('integration tests', () => {
|
||||
|
||||
Reference in New Issue
Block a user