Skip to content

Commit

Permalink
Add support for punctuations in deoida
Browse files Browse the repository at this point in the history
  • Loading branch information
twobiers committed Dec 30, 2023
1 parent fae23fb commit d6fbbab
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/storage/model/AustrianTranslation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,24 @@ export default class AustrianTranslation extends Model {
): Promise<AustrianTranslation | null> {
return AustrianTranslation.findOne({
where: {
austrian: {
// we want like to be case-insensitive, we don't need a placeholder
[Op.like]: austrian.trim().toLowerCase(),
},
[Op.or]: [
{
// we want like to be case-insensitive, we don't need a placeholder
// We might have translations with punctuations in it, so we simply try to match the whole string against it
austrian: {
[Op.like]: austrian.trim().toLowerCase(),
},
},
{
// If we couldn't find a translation with the punctuations in it, we remove the special chars
austrian: {
[Op.like]: austrian
.trim()
.toLowerCase()
.replace(/[^\w\s]/gu, ""),
},
},
],
},
});
}
Expand Down

0 comments on commit d6fbbab

Please sign in to comment.