mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Node 15
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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, ''));
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user