Skip to content

Commit

Permalink
Fix a conflict if the var path is used by another scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
AmauriC committed Feb 28, 2024
1 parent ae076de commit a089de7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions tarteaucitron.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
/* min ready */

var scripts = document.getElementsByTagName('script'),
path = (document.currentScript || scripts[scripts.length - 1]).src.split('?')[0],
tarteaucitronPath = (document.currentScript || scripts[scripts.length - 1]).src.split('?')[0],
tarteaucitronForceCDN = (tarteaucitronForceCDN === undefined) ? '' : tarteaucitronForceCDN,
tarteaucitronUseMin = (tarteaucitronUseMin === undefined) ? '' : tarteaucitronUseMin,
cdn = (tarteaucitronForceCDN === '') ? path.split('/').slice(0, -1).join('/') + '/' : tarteaucitronForceCDN,
cdn = (tarteaucitronForceCDN === '') ? tarteaucitronPath.split('/').slice(0, -1).join('/') + '/' : tarteaucitronForceCDN,
alreadyLaunch = (alreadyLaunch === undefined) ? 0 : alreadyLaunch,
tarteaucitronForceLanguage = (tarteaucitronForceLanguage === undefined) ? '' : tarteaucitronForceLanguage,
tarteaucitronForceExpire = (tarteaucitronForceExpire === undefined) ? '' : tarteaucitronForceExpire,
Expand Down Expand Up @@ -204,7 +204,7 @@ var tarteaucitron = {

var cdn = tarteaucitron.cdn,
language = tarteaucitron.getLanguage(),
useMinifiedJS = ((cdn.indexOf('cdn.jsdelivr.net') >= 0) || (path.indexOf('.min.') >= 0) || (tarteaucitronUseMin !== '')),
useMinifiedJS = ((cdn.indexOf('cdn.jsdelivr.net') >= 0) || (tarteaucitronPath.indexOf('.min.') >= 0) || (tarteaucitronUseMin !== '')),
pathToLang = cdn + 'lang/tarteaucitron.' + language + (useMinifiedJS ? '.min' : '') + '.js',
pathToServices = cdn + 'tarteaucitron.services' + (useMinifiedJS ? '.min' : '') + '.js',
linkElement = document.createElement('link'),
Expand Down
2 changes: 1 addition & 1 deletion tarteaucitron.min.js

Large diffs are not rendered by default.

0 comments on commit a089de7

Please sign in to comment.