From aa1d22ec796dc6ccf8344a5f04a3ab98b195ae40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 8 Dec 2017 11:37:57 -0500 Subject: [PATCH] handle relative images --- src/controllers/topics.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/controllers/topics.js b/src/controllers/topics.js index 548b8eceb2..491d37d1e0 100644 --- a/src/controllers/topics.js +++ b/src/controllers/topics.js @@ -288,7 +288,7 @@ function addTags(topicData, req, res) { }, ]; - var regex = /src\s*=\s*"(.+?)"/g; + var regex = /src\s*=\s*"(.+?)"/; topicData.posts.forEach(function (postData) { var match = regex.exec(postData.content); @@ -297,6 +297,9 @@ function addTags(topicData, req, res) { if (image.startsWith(nconf.get('url') + '/plugins')) { return; } + if (!image.startsWith('http')) { + image = nconf.get('url') + image; + } res.locals.metaTags.push({ property: 'og:image', content: image,