From ecd48a4b359d30204d9c9d3412a704ec34e5d1ce Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 10 Jul 2015 15:56:23 -0400 Subject: [PATCH] FIX: When finding a topic by slug only, use replaceState --- app/assets/javascripts/discourse/lib/url.js | 23 +++++++++---------- .../discourse/routes/topic-by-slug.js.es6 | 2 +- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/app/assets/javascripts/discourse/lib/url.js b/app/assets/javascripts/discourse/lib/url.js index 3742887ab32..f0726dbbdab 100644 --- a/app/assets/javascripts/discourse/lib/url.js +++ b/app/assets/javascripts/discourse/lib/url.js @@ -104,11 +104,8 @@ Discourse.URL = Ember.Object.createWithMixins({ It contains the logic necessary to route within a topic using replaceState to keep the history intact. - - @method routeTo - @param {String} path The path we are routing to. **/ - routeTo: function(path) { + routeTo: function(path, opts) { if (Em.isEmpty(path)) { return; } if (Discourse.get('requiresRefresh')) { @@ -166,7 +163,7 @@ Discourse.URL = Ember.Object.createWithMixins({ this.appEvents.trigger('url:refresh'); } - return this.handleURL(path); + return this.handleURL(path, opts); }, rewrite: function(regexp, replacement) { @@ -310,17 +307,19 @@ Discourse.URL = Ember.Object.createWithMixins({ }, /** - @private - Be wary of looking up the router. In this case, we have links in our HTML, say form compiled markdown posts, that need to be routed. - - @method handleURL - @param {String} path the url to handle **/ - handleURL: function(path) { + handleURL: function(path, opts) { + opts = opts || {}; + var router = this.get('router'); - router.router.updateURL(path); + + if (opts.replaceURL) { + this.replaceState(path); + } else { + router.router.updateURL(path); + } var split = path.split('#'), elementId; diff --git a/app/assets/javascripts/discourse/routes/topic-by-slug.js.es6 b/app/assets/javascripts/discourse/routes/topic-by-slug.js.es6 index 898fbfe65e5..a001be7f5d0 100644 --- a/app/assets/javascripts/discourse/routes/topic-by-slug.js.es6 +++ b/app/assets/javascripts/discourse/routes/topic-by-slug.js.es6 @@ -6,6 +6,6 @@ export default Discourse.Route.extend({ }, afterModel: function(result) { - Discourse.URL.routeTo(result.url); + Discourse.URL.routeTo(result.url, { replaceURL: true }); } });