From 0a4ffde6d468f11d8121c3f7c1d78c32dbecf1e5 Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Mon, 4 May 2015 11:49:53 -0300 Subject: [PATCH] Refactoring the base url capture function --- index.html | 20 +++----------------- js/requirejs-config.js | 3 +-- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/index.html b/index.html index ca0c794..3b0076a 100644 --- a/index.html +++ b/index.html @@ -15,29 +15,15 @@ var Url = (function(){ return { - initBase: function(){ - var base = window.location.href; - var host = window.location.host; - var regex = new RegExp(".*" + host + '/', "g"); - - if(host){ - base = base.replace(regex,''); - }else{ - base = base.replace('index.html',''); - } - return base - }, - removeUrlParameters: function(full_url){ - var url_base = full_url.split('#').shift(); - return url_base; + return "//" + window.location.host + window.location.pathname.replace('/index.html',''); }, - addBaseUrl: function(filename){ + addBaseUrl: function(filename){ var base = window.location.href; if(base.match(/file:/) || filename.match(/http:/)){ base = ''; }else{ - base = this.removeUrlParameters(base) + '/'; + base = this.initBase() + '/'; } return base + filename; } diff --git a/js/requirejs-config.js b/js/requirejs-config.js index cbe8487..d2bb5f0 100644 --- a/js/requirejs-config.js +++ b/js/requirejs-config.js @@ -1,6 +1,5 @@ if(window.Url){ - var base = Url.initBase(); - base = Url.removeUrlParameters(base) + '/js/'; + var base = Url.initBase() + '/js/'; }else{ base = '../js' } -- libgit2 0.21.2