reddit-radio icon indicating copy to clipboard operation
reddit-radio copied to clipboard

Artists with special charachters like 'ø', and 'Ø' are hard to find

Open DyonR opened this issue 2 years ago • 0 comments

Some artists, like Røza, F. NøIzE, MØSCARDO, and APHØTHIC are hard to find with the current find command.
The reason for this is, is that the bot does not take diacritical marks/accents into account. My Javascript knowledge is not amazing, so I asked ChatGPT for a concept fix.
I don't fully understand this, but maybe you could use this as a basis for a fix.

findSets(query)
{
	// Normalize the query
	query = query.toLowerCase().replace(/[oø]/g, 'o');

	var ret = [];
	for (var i = 0; i < this.schedule.length; i++) {
		var stage = this.schedule[i];
		for (var j = 0; j < stage.sets.length; j++) {
			var set = stage.sets[j];
			if (set.nothing) {
				continue;
			}
			// Normalize the set name
			var setNameNormalized = set.name.toLowerCase().replace(/[oø]/g, 'o');
			// Normalize the set.who if it exists
			var setWhoNormalized = set.who ? set.who.toLowerCase().replace(/[oø]/g, 'o') : null;

			if (setNameNormalized.indexOf(query) != -1 || (setWhoNormalized && setWhoNormalized.indexOf(query) != -1)) {
				ret.push({
					set: set,
					stage: stage
				});
			}
		}
	}
	return ret;
}

DyonR avatar Jun 21 '23 23:06 DyonR