From c414db107c50f4692de7ec3dd37279b2d17fb07b Mon Sep 17 00:00:00 2001 From: Daniel Waterworth Date: Fri, 29 Nov 2019 11:53:05 +0000 Subject: [PATCH] FIX: Handle none path correctly with three levels With a path like "/c/foo/1/none", "none" was being interpreted as an id. --- .../routes/build-category-route.js.es6 | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/discourse/routes/build-category-route.js.es6 b/app/assets/javascripts/discourse/routes/build-category-route.js.es6 index e487570d5ab..56c984a53f7 100644 --- a/app/assets/javascripts/discourse/routes/build-category-route.js.es6 +++ b/app/assets/javascripts/discourse/routes/build-category-route.js.es6 @@ -18,13 +18,27 @@ export default (filterArg, params) => { serialize(modelParams) { if (!modelParams.category_slug_path_with_id) { - modelParams.category_slug_path_with_id = [ - modelParams.parentSlug, - modelParams.slug, - modelParams.id - ] - .filter(x => x) - .join("/"); + if (modelParams.id === "none") { + const category_slug_path_with_id = [ + modelParams.parentSlug, + modelParams.slug + ].join("/"); + const category = Category.findBySlugPathWithID( + category_slug_path_with_id + ); + this.replaceWith("discovery.categoryNone", { + category, + category_slug_path_with_id + }); + } else { + modelParams.category_slug_path_with_id = [ + modelParams.parentSlug, + modelParams.slug, + modelParams.id + ] + .filter(x => x) + .join("/"); + } } return modelParams;