Skip to content

A platform for community discussion. Free, open, simple.

FIX: Handle none path correctly with three levels

Daniel Waterworthc414db107c50
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;