FIX: Handle none path correctly with three levels

With a path like "/c/foo/1/none", "none" was being interpreted as an id.
This commit is contained in:
Daniel Waterworth 2019-11-29 11:53:05 +00:00
parent 3cf4ba5069
commit c414db107c

View File

@ -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;