From f00200a6dda4c1b28ca4f14e4e65f8a8d0ec4dc2 Mon Sep 17 00:00:00 2001 From: Yaacov Date: Tue, 25 Feb 2020 09:41:22 +0100 Subject: [PATCH 1/2] fix(js): select the relevant script to define the correct path for files inclusion See https://stackoverflow.com/a/22745553/5487370 --- tarteaucitron.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tarteaucitron.js b/tarteaucitron.js index 23fab4c..cf8988f 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -1,8 +1,19 @@ /*jslint browser: true, evil: true */ -// define correct path for files inclusion var scripts = document.getElementsByTagName('script'), - path = scripts[scripts.length - 1].src.split('?')[0], + thisScript = null; +for (var i = 0, il = scripts.length; i < il; ++i) { + if ( scripts[i].getAttribute('src').indexOf('tarteaucitron.js') >= 0) { + // should always find this script + thisScript = scripts[i]; + break; + } + // should never happen + throw new Error("Error: tarteaucitron.js script not found"); +} + +// define correct path for files inclusion +var path = thisScript.src.split('?')[0], tarteaucitronForceCDN = (tarteaucitronForceCDN === undefined) ? '' : tarteaucitronForceCDN, cdn = (tarteaucitronForceCDN === '') ? path.split('/').slice(0, -1).join('/') + '/' : tarteaucitronForceCDN, alreadyLaunch = (alreadyLaunch === undefined) ? 0 : alreadyLaunch, From 28dbc2de75b437bccee8470dc42836b2ef9e8ef0 Mon Sep 17 00:00:00 2001 From: Yaacov Date: Wed, 4 Mar 2020 00:54:18 +0100 Subject: [PATCH 2/2] fix(tarteaucitron) select the relevant script to define the right path (bis) --- tarteaucitron.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tarteaucitron.js b/tarteaucitron.js index cf8988f..5b80be6 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -3,7 +3,7 @@ var scripts = document.getElementsByTagName('script'), thisScript = null; for (var i = 0, il = scripts.length; i < il; ++i) { - if ( scripts[i].getAttribute('src').indexOf('tarteaucitron.js') >= 0) { + if ( scripts[i].getAttribute('src').indexOf('tarteaucitron') >= 0) { // should always find this script thisScript = scripts[i]; break;