Commit 3bcc24c2e8ba5c7392ad4c3b90dbb422167299c6
use `localeCompare` with base matching for suggest completion
matches all letter variants including with diacratics fixes #750Matt McKegg committed on 3/26/2018, 10:06:54 AM
Parent: 7a2806f51cfcc2a146b0f508dbfde798a1fa11c3
Files changed
modules/channel/obs/suggest.js | changed |
modules/profile/async/suggest.js | changed |
modules/channel/obs/suggest.js | ||
---|---|---|
@@ -20,9 +20,9 @@ | ||
20 | 20 | if (!word) { |
21 | 21 | return suggestions().slice(0, 200) |
22 | 22 | } else { |
23 | 23 | return suggestions().filter((item) => { |
24 | - return item.title.toLowerCase().startsWith(word.toLowerCase()) | |
24 | + return matches(item.title, word) | |
25 | 25 | }) |
26 | 26 | } |
27 | 27 | } |
28 | 28 | }) |
@@ -72,4 +72,8 @@ | ||
72 | 72 | } else { |
73 | 73 | return fallback || '' |
74 | 74 | } |
75 | 75 | } |
76 | + | |
77 | +function matches (text, startsWith) { | |
78 | + return text.slice(0, startsWith.length).localeCompare(startsWith, 'default', {sensitivity: 'base'}) === 0 | |
79 | +} |
modules/profile/async/suggest.js | ||
---|---|---|
@@ -98,8 +98,7 @@ | ||
98 | 98 | return 'following' |
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
102 | -function matches (title, match) { | |
103 | - if (!match) return true | |
104 | - return title.toLowerCase().startsWith(match.toLowerCase()) | |
102 | +function matches (text, startsWith) { | |
103 | + return text.slice(0, startsWith.length).localeCompare(startsWith, 'default', {sensitivity: 'base'}) === 0 | |
105 | 104 | } |
Built with git-ssb-web