Skip to content

Commit

Permalink
Remove hardcoded limit from slug building function
Browse files Browse the repository at this point in the history
  • Loading branch information
enduvar committed May 15, 2021
1 parent 165820b commit 8e1c083
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions app/assets/javascripts/discourse/app/models/category.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,17 +337,20 @@ Category.reopenClass({
return _uncategorized;
},

slugFor(category, separator = "/", depth = 3) {
slugFor(category, separator = "/", depth) {
if (!category) {
return "";
}

const parentCategory = get(category, "parentCategory");
let result = "";

if (parentCategory && depth > 1) {
result =
Category.slugFor(parentCategory, separator, depth - 1) + separator;
if (parentCategory) {
if (typeof depth === 'undefined') {
result = Category.slugFor(parentCategory, separator) + separator;
} else if (depth > 1) {
result = Category.slugFor(parentCategory, separator, depth - 1) + separator;
}
}

const id = get(category, "id"),
Expand Down

0 comments on commit 8e1c083

Please sign in to comment.