From: Guillaume Pellerin Date: Thu, 16 May 2013 13:36:51 +0000 (+0200) Subject: fix resource load when server has ngx_pagespeed module installed (closes: #14) X-Git-Tag: 0.4.4~7 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=bebcff8525e1c309dac03d0c8728c20b84aedd7d;p=timeside.git fix resource load when server has ngx_pagespeed module installed (closes: #14) --- diff --git a/timeside/static/timeside/js/timeside.js b/timeside/static/timeside/js/timeside.js index c764d46..e274783 100644 --- a/timeside/static/timeside/js/timeside.js +++ b/timeside/static/timeside/js/timeside.js @@ -568,20 +568,15 @@ Timeside.load =function(config){ var loadAll = function() { - //get the current script path (this file name is timeside.js?... or simplt timeside.js) + //get the current script path (this file name is timeside.js, or timeside.js?..., or even timeside.js.pagespeed.blah.js) var scripts = $J('script'); var thisScriptPath = ''; scripts.each(function(i,s){ var src = $J(s).attr('src'); - if(src){ - var srcName = src.split(/\//); - if(srcName.length){ - srcName = srcName[srcName.length-1]; - //is this script ? consider the case here we are loading timeside.js?.... - if(srcName.replace(/\.js(?:\?[^\?]*)*$/,'.js') == 'timeside.js'){ - src[src.length-1] = ''; - thisScriptPath = src.replace(/\/[^\/]+$/, ''); - } + if(src) { + var m = src.match(/^([^?]*\/)timeside.js/); + if (m) { + thisScriptPath = m[1]; } } });