From bebcff8525e1c309dac03d0c8728c20b84aedd7d Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Thu, 16 May 2013 15:36:51 +0200 Subject: [PATCH] fix resource load when server has ngx_pagespeed module installed (closes: #14) --- timeside/static/timeside/js/timeside.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) 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]; } } }); -- 2.39.5