This commit is contained in:
Dragon Fire
2020-10-24 14:25:32 -04:00
parent 40080cadef
commit ebd26a7b0e
25 changed files with 42 additions and 44 deletions
+2 -2
View File
@@ -6,7 +6,7 @@ module.exports = class Pokemon {
constructor(store, data) {
this.store = store;
this.id = data.id;
const slugName = firstUpperCase(data.name).replace(/-/g, ' ');
const slugName = firstUpperCase(data.name).replaceAll('-', ' ');
this.name = data.names.length
? data.names.find(entry => entry.language.name === 'en').name
: slugName;
@@ -22,7 +22,7 @@ module.exports = class Pokemon {
this.varieties = data.varieties.map(variety => {
const name = firstUpperCase(variety.pokemon.name
.replace(new RegExp(`${this.slug}-?`, 'i'), '')
.replace(/-/g, ' '));
.replaceAll('-', ' '));
return {
id: variety.pokemon.name,
name: name || null,
+1 -1
View File
@@ -28,6 +28,6 @@ module.exports = class PokemonStore extends Collection {
}
makeSlug(query) {
return encodeURIComponent(query.toLowerCase().replace(/ /g, '-').replace(/[^a-zA-Z0-9-]/g, ''));
return encodeURIComponent(query.toLowerCase().replaceAll(' ', '-').replace(/[^a-zA-Z0-9-]/g, ''));
}
};