Skip to content

Commit

Permalink
Check GET parameters in image embedding
Browse files Browse the repository at this point in the history
This is a great candidate for the tests!
  • Loading branch information
lorenzhs committed Aug 18, 2014
1 parent 1235a5e commit b939bc7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions js/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/");
Expand Down

0 comments on commit b939bc7

Please sign in to comment.