FIX: currentURL may be incorrect sometimes

FIX: currentURL may be incorrect sometimes

When transitioning only using queryParams under some conditions currentURL will not update. Using queryParams is both cleaner and less fragile.

diff --git a/assets/javascripts/discourse/initializers/discourse-voting.js.es6 b/assets/javascripts/discourse/initializers/discourse-voting.js.es6
index a2af038..f87ec4f 100644
--- a/assets/javascripts/discourse/initializers/discourse-voting.js.es6
+++ b/assets/javascripts/discourse/initializers/discourse-voting.js.es6
@@ -17,8 +17,11 @@ export default {
             return `${Discourse.BaseUri}/${args.filterMode}?order=votes`;
           },
           forceActive: (category, args, router) => {
+            const queryParams = router.currentRoute.queryParams;
             return (
-              router.currentURL && router.currentURL.indexOf("order=votes") > -1
+              queryParams &&
+              Object.keys(queryParams).length === 1 &&
+              queryParams["order"] === "votes"
             );
           }
         });

GitHub sha: a97026b2

1 Like