cli tool: handle accents in filter

This commit is contained in:
quenousimporte 2023-08-25 17:44:24 +02:00
parent bb1730f2b2
commit c48da6d245
1 changed files with 6 additions and 1 deletions

View File

@ -15,6 +15,11 @@ var filter = process.argv.length > 2 ? process.argv[2] : "";
var intervalid = null; var intervalid = null;
var notes = null; var notes = null;
function simplifystring(str)
{
return str.toLowerCase().normalize('NFD').replace(/\p{Diacritic}/gu, "");
}
async function decrypt(str) async function decrypt(str)
{ {
var key = pgpkey.split("-----END PGP PUBLIC KEY BLOCK-----")[1]; var key = pgpkey.split("-----END PGP PUBLIC KEY BLOCK-----")[1];
@ -41,7 +46,7 @@ async function encrypt(str)
function filteredlist() function filteredlist()
{ {
return notes return notes
.filter(n => n.title.toLowerCase().includes(filter.toLowerCase())); .filter(n => simplifystring(n.title).includes(simplifystring(filter)));
} }
axios.post(`${settings.url}/handler.php`, axios.post(`${settings.url}/handler.php`,