A platform for community discussion. Free, open, simple.
Add baseUri to site model
Régis Hanolf56a746d71b3
diff --git a/app/assets/javascripts/discourse/lib/url.js.es6 b/app/assets/javascripts/discourse/lib/url.js.es6index 487b4467f9b..16acbbf2655 100644--- a/app/assets/javascripts/discourse/lib/url.js.es6+++ b/app/assets/javascripts/discourse/lib/url.js.es6@@ -81,6 +81,7 @@ const DiscourseURL = Ember.Object.extend({const holderId = `#post_${postNumber}`;_transitioning = postNumber > 1;+Ember.run.schedule('afterRender', () => {let elementId;let holder;@@ -107,7 +108,7 @@ const DiscourseURL = Ember.Object.extend({}});- if (holder.length > 0 && opts && opts.skipIfOnScreen){+ if (holder.length > 0 && opts && opts.skipIfOnScreen) {const elementTop = lockon.elementTop();const scrollTop = $(window).scrollTop();const windowHeight = $(window).height() - offsetCalculator();@@ -172,7 +173,7 @@ const DiscourseURL = Ember.Object.extend({}const pathname = path.replace(/(https?\:)?\/\/[^\/]+/, '');- let baseUri = Discourse.BaseUri;+ const baseUri = Discourse.BaseUri;// If we have a baseUri and an absolute URL, make sure the baseUri// is the same. Otherwise we could be switching forums.@@ -217,18 +218,18 @@ const DiscourseURL = Ember.Object.extend({}// handle prefixes- if (path.match(/^\//)) {- let rootURL = (baseUri === undefined ? "/" : baseUri);- rootURL = rootURL.replace(/\/$/, '');- path = path.replace(rootURL, '');+ if (path.indexOf("/") === 0) {+ const rootURL = (baseUri === undefined ? "/" : baseUri).replace(/\/$/, "");+ path = path.replace(rootURL, "");}path = rewritePath(path);+if (this.navigatedToPost(oldPath, path, opts)) { return; }if (oldPath === path) {- // If navigating to the same path send an app event. Views can watch it- // and tell their controllers to refresh+ // If navigating to the same path send an app event.+ // Views can watch it and tell their controllers to refreshthis.appEvents.trigger('url:refresh');}diff --git a/app/assets/javascripts/discourse/models/site.js.es6 b/app/assets/javascripts/discourse/models/site.js.es6index 073f6b43f9b..c1e3889176c 100644--- a/app/assets/javascripts/discourse/models/site.js.es6+++ b/app/assets/javascripts/discourse/models/site.js.es6@@ -54,6 +54,11 @@ const Site = RestModel.extend({return result;},+ @computed+ baseUri() {+ return Discourse.baseUri;+ },+// Returns it in the correct order, by setting@computedcategoriesList() {