From 63323bd7a8ff2128abf10c675bcad225dab13cd2 Mon Sep 17 00:00:00 2001 From: Jeff Wong Date: Mon, 23 Dec 2019 10:24:41 -0800 Subject: [PATCH] FIX: category routes model params should decode their URL parts (#8612) * FIX: category routes model params should decode their URL parts Ember's route star globbing does not uri decode by default. This is problematic for subcategory globs with encoded URL site settings enabled. Subcategories with encoded URLs will 404 without this decode. I found this https://github.com/tildeio/route-recognizer/pull/91 which explicitly explains that globbing does not decode automatically. --- app/assets/javascripts/discourse/models/category.js.es6 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/models/category.js.es6 b/app/assets/javascripts/discourse/models/category.js.es6 index a1dada71880..78832ccbf35 100644 --- a/app/assets/javascripts/discourse/models/category.js.es6 +++ b/app/assets/javascripts/discourse/models/category.js.es6 @@ -334,7 +334,11 @@ Category.reopenClass({ }, findBySlugPathWithID(slugPathWithID) { - const parts = slugPathWithID.split("/"); + let parts = slugPathWithID.split("/"); + // slugs found by star/glob pathing in emeber do not automatically url decode - ensure that these are decoded + if (Discourse.SiteSettings.slug_generation_method === "encoded") { + parts = parts.map(urlPart => decodeURI(urlPart)); + } let category = null; if (parts.length > 0 && parts[parts.length - 1].match(/^\d+$/)) {