DEV: Remove 'dasherize' string prototype extensions (#173)

Context: https://deprecations.emberjs.com/v3.x/#toc_ember-string-prototype_extensions
This commit is contained in:
Isaac Janzen 2022-05-13 12:43:37 -05:00 committed by GitHub
parent d5e11a2c65
commit 01f52dc5c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -1,6 +1,7 @@
import I18n from "I18n"; import I18n from "I18n";
import { default as computed } from "discourse-common/utils/decorators"; import { default as computed } from "discourse-common/utils/decorators";
import Category from "discourse/models/category"; import Category from "discourse/models/category";
import { dasherize } from "@ember/string";
const layoutMap = { const layoutMap = {
int: "int", int: "int",
@ -100,8 +101,8 @@ export default Ember.Component.extend({
case "post_id": case "post_id":
return isPositiveInt || /\d+\/\d+(\?u=.*)?$/.test(value); return isPositiveInt || /\d+\/\d+(\?u=.*)?$/.test(value);
case "category_id": case "category_id":
if (!isPositiveInt && value !== value.dasherize()) { if (!isPositiveInt && value !== dasherize(value)) {
this.set("value", value.dasherize()); this.set("value", dasherize(value));
} }
if (isPositiveInt) { if (isPositiveInt) {
@ -112,12 +113,12 @@ export default Ember.Component.extend({
return false; return false;
} }
const result = Category.findBySlug( const result = Category.findBySlug(
match[2].dasherize(), dasherize(match[2]),
match[1].dasherize() dasherize(match[1])
); );
return !!result; return !!result;
} else { } else {
return !!Category.findBySlug(value.dasherize()); return !!Category.findBySlug(dasherize(value));
} }
case "group_id": case "group_id":
const groups = this.site.get("groups"); const groups = this.site.get("groups");