From 55b720466b92ad18de98bcfaee6f42f649bda886 Mon Sep 17 00:00:00 2001 From: Vivien Didelot Date: Thu, 17 Oct 2013 18:20:04 -0400 Subject: [PATCH] plugins: (image) support fukung.net Links to http://fukung.net/v/foobar.gif end by the actual image extensions, but the full image path is under http://media.fukung.net/imgs/foobar.gif. This commit replace the URL prefix if it matches fukung.net/v/. --- js/plugins.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/js/plugins.js b/js/plugins.js index c1ad7f4..1880d3e 100644 --- a/js/plugins.js +++ b/js/plugins.js @@ -150,16 +150,24 @@ plugins.factory('userPlugins', function() { * Image Preview */ var imagePlugin = new Plugin(function(message) { - - var url = message.match(urlRegexp); - if (url) { - var url = url[0]; /* Actually parse one url per message */ + var url = message.match(urlRegexp); + var content = null; + + if (url) { + var url = url[0]; /* Actually parse one url per message */ if (url.match(/png$|gif$|jpg$|jpeg$/)) { - return ''; - } + + /* A fukung.net URL may end by an image extension but is not a direct link. */ + if (url.indexOf("fukung.net/v/") != -1) { + url = url.replace(/.*\//, "http://media.fukung.net/imgs/") + } + + content = ''; + } } - return null; + + return content; }); imagePlugin.name = 'image';