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();
});
});