diff --git a/app/assets/javascripts/discourse/app/lib/url.js b/app/assets/javascripts/discourse/app/lib/url.js index 996a51f94dd..53b2f3e70c3 100644 --- a/app/assets/javascripts/discourse/app/lib/url.js +++ b/app/assets/javascripts/discourse/app/lib/url.js @@ -506,9 +506,12 @@ export function getCategoryAndTagUrl(category, subcategories, tag) { if (category) { url = category.path; - if (subcategories && category.default_list_filter === "none") { + if (subcategories && (category.default_list_filter === "none" || tag)) { url += "/all"; - } else if (!subcategories && category.default_list_filter === "all") { + } else if ( + !subcategories && + (category.default_list_filter === "all" || tag) + ) { url += "/none"; } } diff --git a/app/assets/javascripts/discourse/tests/unit/lib/url-test.js b/app/assets/javascripts/discourse/tests/unit/lib/url-test.js index 1d1cc04dc89..9f8380c47e2 100644 --- a/app/assets/javascripts/discourse/tests/unit/lib/url-test.js +++ b/app/assets/javascripts/discourse/tests/unit/lib/url-test.js @@ -141,6 +141,34 @@ module("Unit | Utility | url", function () { ), "/c/foo/1" ); + + assert.strictEqual( + getCategoryAndTagUrl( + { path: "/c/foo/1", default_list_filter: "none" }, + false, + "bar" + ), + "/tags/c/foo/1/none/bar" + ); + + assert.strictEqual( + getCategoryAndTagUrl({ path: "/c/foo/1" }, false, "bar"), + "/tags/c/foo/1/none/bar" + ); + + assert.strictEqual( + getCategoryAndTagUrl( + { path: "/c/foo/1", default_list_filter: "all" }, + true, + "bar" + ), + "/tags/c/foo/1/all/bar" + ); + + assert.strictEqual( + getCategoryAndTagUrl({ path: "/c/foo/1" }, true, "bar"), + "/tags/c/foo/1/all/bar" + ); }); test("routeTo redirects secure uploads URLS because they are server side only", async function (assert) {