Commit 0a4ffde6d468f11d8121c3f7c1d78c32dbecf1e5

Authored by Victor Costa
1 parent 13e18eaf

Refactoring the base url capture function

Showing 2 changed files with 4 additions and 19 deletions   Show diff stats
@@ -15,29 +15,15 @@ @@ -15,29 +15,15 @@
15 var Url = (function(){ 15 var Url = (function(){
16 16
17 return { 17 return {
18 -  
19 initBase: function(){ 18 initBase: function(){
20 - var base = window.location.href;  
21 - var host = window.location.host;  
22 - var regex = new RegExp(".*" + host + '/', "g");  
23 -  
24 - if(host){  
25 - base = base.replace(regex,'');  
26 - }else{  
27 - base = base.replace('index.html','');  
28 - }  
29 - return base  
30 - },  
31 - removeUrlParameters: function(full_url){  
32 - var url_base = full_url.split('#').shift();  
33 - return url_base; 19 + return "//" + window.location.host + window.location.pathname.replace('/index.html','');
34 }, 20 },
35 - addBaseUrl: function(filename){ 21 + addBaseUrl: function(filename){
36 var base = window.location.href; 22 var base = window.location.href;
37 if(base.match(/file:/) || filename.match(/http:/)){ 23 if(base.match(/file:/) || filename.match(/http:/)){
38 base = ''; 24 base = '';
39 }else{ 25 }else{
40 - base = this.removeUrlParameters(base) + '/'; 26 + base = this.initBase() + '/';
41 } 27 }
42 return base + filename; 28 return base + filename;
43 } 29 }
js/requirejs-config.js
1 if(window.Url){ 1 if(window.Url){
2 - var base = Url.initBase();  
3 - base = Url.removeUrlParameters(base) + '/js/'; 2 + var base = Url.initBase() + '/js/';
4 }else{ 3 }else{
5 base = '../js' 4 base = '../js'
6 } 5 }