From a2ab9a2b8cdbef7bb531ed7dea2d571cf214b327 Mon Sep 17 00:00:00 2001 From: Lapo Luchini Date: Wed, 28 May 2014 15:58:00 +0200 Subject: [PATCH] Use `.src` to get absolute URL as calculated by the browser. --- pinry/static/js/bookmarklet.js | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/pinry/static/js/bookmarklet.js b/pinry/static/js/bookmarklet.js index e6abe5c..380a97e 100644 --- a/pinry/static/js/bookmarklet.js +++ b/pinry/static/js/bookmarklet.js @@ -30,15 +30,6 @@ function main() { var formUrl = '/pins/pin-form/?pin-image-url='; return 'http://'+hostUrl+formUrl; } - - function normalizeImageUrl(imageUrl) { - var protocol = imageUrl.split(':')[0]; - if (protocol != 'http' && protocol != 'https') { - if (imageUrl[1] != '/') - imageUrl = 'http://'+window.location.host+imageUrl; - } - return imageUrl; - } // End Helper Functions @@ -80,7 +71,6 @@ function main() { function imageView(imageUrl) { // Requires that pageView has been created already - imageUrl = normalizeImageUrl(imageUrl); var image = document.createElement('div'); $(image).css({ 'background-image': 'url('+imageUrl+')', @@ -108,7 +98,7 @@ function main() { var images = $('body').find('img'); images.each(function() { if ($(this).width() > 200 && $(this).height() > 200) - imageView($(this).attr('src')); + imageView(this.src); }); return images; }