From fab606e3a5e69170a39bc8d62016647116e4480d Mon Sep 17 00:00:00 2001 From: David Mondok <3883758+davidmondok@users.noreply.github.com> Date: Fri, 10 Dec 2021 17:53:49 +0100 Subject: [PATCH] Normalize list items like the input value to allow matching umlauts (#149) --- index.js | 2 +- test/test.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index b49867a..c758928 100644 --- a/index.js +++ b/index.js @@ -54,7 +54,7 @@ alfy.matches = (input, list, item) => { } if (typeof listItem === 'string') { - listItem = listItem.toLowerCase(); + listItem = listItem.toLowerCase().normalize(); } if (typeof item === 'function') { diff --git a/test/test.js b/test/test.js index a22b868..da0ca92 100644 --- a/test/test.js +++ b/test/test.js @@ -30,4 +30,7 @@ test('.matches()', t => { test('.inputMatches()', t => { t.deepEqual(alfyInstance.inputMatches(['foo', 'unicorn']), ['unicorn']); + alfyInstance.input = 'Ünicörn'; + t.deepEqual(alfyInstance.inputMatches(['foo', 'unicorn']), []); + t.deepEqual(alfyInstance.inputMatches(['foo', 'ünicörn']), ['ünicörn']); });