From 7948a8d13c99e12899253ffcbfd826fb02128dde Mon Sep 17 00:00:00 2001 From: TN1ck Date: Mon, 26 Sep 2016 18:06:57 +0200 Subject: [PATCH] fixed cors issue with different ports on same host --- resemble.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/resemble.js b/resemble.js index 2626a6d..b0051d9 100644 --- a/resemble.js +++ b/resemble.js @@ -66,10 +66,11 @@ URL: https://github.com/Huddle/Resemble.js var errorPixelTransformer = errorPixelTransform.flat; var largeImageThreshold = 1200; - + var httpRegex = /^https?:\/\//; var document = typeof window != "undefined" ? window.document : {}; - var documentDomainRegex = new RegExp('^https?://' + document.domain); + var location = typeof window != "undefined" ? window.location : {}; + var documentDomainRegex = new RegExp('^https?://' + location.href.split("/")[2]); var resemble = function( fileData ){ @@ -151,10 +152,10 @@ URL: https://github.com/Huddle/Resemble.js hiddenImage.setAttribute('crossorigin', 'anonymous'); - hiddenImage.onerror = function () { + hiddenImage.onerror = function () { hiddenImage.onerror = null; //fixes pollution between calls images.push({ error : "Image load error."}); - callback(); + callback(); }; hiddenImage.onload = function() {