From 3049f5cf1f5fd502e9407aec19bbc6d7dca95130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Sun, 28 May 2017 01:26:56 -0400 Subject: [PATCH] #5522 test --- src/posts/parse.js | 4 ++-- test/posts.js | 13 +++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/posts/parse.js b/src/posts/parse.js index 4c5bdded9f..d46eaa800d 100644 --- a/src/posts/parse.js +++ b/src/posts/parse.js @@ -12,13 +12,13 @@ var plugins = require('../plugins'); var translator = require('../translator'); module.exports = function (Posts) { - Posts.urlRegex = { regex: /href="([^"]+)"/g, length: 6, }; + Posts.imgRegex = { - regex:/src="([^"]+)"/g, + regex: /src="([^"]+)"/g, length: 5, }; diff --git a/test/posts.js b/test/posts.js index b3a5b38056..1f35a3b145 100644 --- a/test/posts.js +++ b/test/posts.js @@ -572,8 +572,17 @@ describe('Post\'s', function () { it('should turn relative links in post body to absolute urls', function (done) { var nconf = require('nconf'); var content = 'test youtube'; - var parsedContent = posts.relativeToAbsolute(content); - assert.equal(parsedContent, 'test youtube'); + var parsedContent = posts.relativeToAbsolute(content, posts.urlRegex); + assert.equal(parsedContent, 'test youtube'); + done(); + }); + + it('should turn relative links in post body to absolute urls', function (done) { + var nconf = require('nconf'); + var content = 'test youtube some test '; + var parsedContent = posts.relativeToAbsolute(content, posts.urlRegex); + parsedContent = posts.relativeToAbsolute(parsedContent, posts.imgRegex); + assert.equal(parsedContent, 'test youtube some test '); done(); }); });