Closed MatthiasRMS closed 4 years ago
I'd recommend adding an extra key, and using speakingurl to normalize it (remove diacritics and such)
const getSlug = require('speakingurl')
// returns "Schoener Titel laesst gruessen!? Bel ete !"
let normalized = getSlug('Schöner Titel läßt grüßen!? Bel été !', {
separator: ' ',
mark: true,
uric: true,
uricNoSlash: true,
maintainCase: true
})
@robozevel thanks for the advice, I can indeed to this! However, wouldn't it be nice to have this built in ?
I'd be happy to work on this and make a PR. @krisk would you accept a PR to add an option ignoring diacritics ?
actually an option to ignore any pattern would be super awesome as well
I solved this:
const removeSpecialCharacters = str => {
return str.normalize('NFD').replace(/[\u0300-\u036f]/g, '')
}
const list = suggestions.map(suggestion => ({
value: suggestion.value,
noSpecialCharacters: removeSpecialCharacters(suggestion.value)
}))
let opts = {
keys: ['value', 'noSpecialCharacters']
...
}
but I agree it could be a parameter. I will try to contribute to this if it is in your interest.
Definitely interesting to cover many languages. The default should be to not be accent-insensitive through to not introduce breaking changes
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days
Is there an option to ignore accents ? Example:
items: [{name: "Référence"}, {name: "Dénomination}]
If I search for
reference
, it won't findRéférence
Is this already possible?
Nb: it does work if you only have those two options, but with a large amount, it doesn't.