diff --git a/app/assets/javascripts/discourse.js b/app/assets/javascripts/discourse.js index d537d42879c..e9ee419a4fe 100644 --- a/app/assets/javascripts/discourse.js +++ b/app/assets/javascripts/discourse.js @@ -22,10 +22,8 @@ Discourse = Ember.Application.createWithMixins({ // The highest seen post number by topic highestSeenByTopic: {}, - rootURL: '/', - getURL: function(url) { - var u = this.get('rootURL'); + var u = (Discourse.BaseUri === undefined ? "/" : Discourse.BaseUri); if (u[u.length-1] === '/') { u = u.substring(0, u.length-1); } diff --git a/app/assets/javascripts/discourse/components/url.js b/app/assets/javascripts/discourse/components/url.js index 0aec6544e6d..4191b874006 100644 --- a/app/assets/javascripts/discourse/components/url.js +++ b/app/assets/javascripts/discourse/components/url.js @@ -13,14 +13,6 @@ Discourse.URL = { // Used for matching a /more URL MORE_REGEXP: /\/more$/, - /** - Will be pre-pended to path upon state change - - @property rootURL - @default '/' - */ - rootURL: '/', - /** @private @@ -73,7 +65,8 @@ Discourse.URL = { If the URL is absolute, remove rootURL */ if (path.match(/^\//)) { - var rootURL = this.rootURL.replace(/\/$/, ''); + var rootURL = (Discourse.BaseUri === undefined ? "/" : Discourse.BaseUri); + rootURL = rootURL.replace(/\/$/, ''); path = path.replace(rootURL, ''); } diff --git a/app/assets/javascripts/discourse/routes/discourse_location.js b/app/assets/javascripts/discourse/routes/discourse_location.js index e01c1d63619..82dcd003167 100644 --- a/app/assets/javascripts/discourse/routes/discourse_location.js +++ b/app/assets/javascripts/discourse/routes/discourse_location.js @@ -35,14 +35,6 @@ Ember.DiscourseLocation = Ember.Object.extend({ set(this, 'history', window.history); }, - /** - Will be pre-pended to path upon state change - - @property rootURL - @default '/' - */ - rootURL: '/', - /** @private @@ -51,7 +43,7 @@ Ember.DiscourseLocation = Ember.Object.extend({ @method getURL */ getURL: function() { - var rootURL = get(this, 'rootURL'), + var rootURL = (Discourse.BaseUri === undefined ? "/" : Discourse.BaseUri), url = get(this, 'location').pathname; rootURL = rootURL.replace(/\/$/, ''); @@ -154,7 +146,7 @@ Ember.DiscourseLocation = Ember.Object.extend({ var currentState = self.get('currentState'); if (currentState) { var url = e.state.path, - rootURL = get(self, 'rootURL'); + rootURL = (Discourse.BaseUri === undefined ? "/" : Discourse.BaseUri); rootURL = rootURL.replace(/\/$/, ''); url = url.replace(rootURL, ''); @@ -176,7 +168,7 @@ Ember.DiscourseLocation = Ember.Object.extend({ @param url {String} */ formatURL: function(url) { - var rootURL = get(this, 'rootURL'); + var rootURL = (Discourse.BaseUri === undefined ? "/" : Discourse.BaseUri); if (url !== '') { rootURL = rootURL.replace(/\/$/, ''); diff --git a/app/views/common/_discourse_javascript.html.erb b/app/views/common/_discourse_javascript.html.erb index 2232cbf9c83..c0c6ead0c4d 100644 --- a/app/views/common/_discourse_javascript.html.erb +++ b/app/views/common/_discourse_javascript.html.erb @@ -35,6 +35,7 @@