Check GET parameters in image embedding

This is a great candidate for the tests!
This commit is contained in:
Lorenz Hübschle-Schneider 2014-08-18 16:41:30 +01:00
parent 1235a5e148
commit b939bc7ca8
1 changed files with 8 additions and 2 deletions

View File

@ -251,8 +251,14 @@ plugins.factory('userPlugins', function() {
*/
var imagePlugin = new Plugin(
urlPlugin(function(url) {
if (url.match(/\.(png|gif|jpg|jpeg)$/i)) {
var embed = false;
// Check the get parameters as well, they might contain an image to load
var segments = url.split(/[?&]/).forEach(function(param) {
if (param.match(/\.(png|gif|jpg|jpeg)$/i)) {
embed = true;
}
});
if (embed) {
/* A fukung.net URL may end by an image extension but is not a direct link. */
if (url.indexOf("^https?://fukung.net/v/") != -1) {
url = url.replace(/.*\//, "http://media.fukung.net/imgs/");