]> git.parisson.com Git - timeside.git/commitdiff
fix resource load when server has ngx_pagespeed module installed (closes: #14)
authorGuillaume Pellerin <yomguy@parisson.com>
Thu, 16 May 2013 13:36:51 +0000 (15:36 +0200)
committerGuillaume Pellerin <yomguy@parisson.com>
Thu, 16 May 2013 13:36:51 +0000 (15:36 +0200)
timeside/static/timeside/js/timeside.js

index c764d46effc21e2cd0312d94914a8a2e24472069..e2747836c28d63f5f55a7a99850b8a6b7d9a0a41 100644 (file)
@@ -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];
                 }
             }
         });