git ssb

10+

Matt McKegg / patchwork



Commit 3bcc24c2e8ba5c7392ad4c3b90dbb422167299c6

use `localeCompare` with base matching for suggest completion

matches all letter variants including with diacratics

fixes #750
Matt McKegg committed on 3/26/2018, 10:06:54 AM
Parent: 7a2806f51cfcc2a146b0f508dbfde798a1fa11c3

Files changed

modules/channel/obs/suggest.jschanged
modules/profile/async/suggest.jschanged
modules/channel/obs/suggest.jsView
@@ -20,9 +20,9 @@
2020 if (!word) {
2121 return suggestions().slice(0, 200)
2222 } else {
2323 return suggestions().filter((item) => {
24- return item.title.toLowerCase().startsWith(word.toLowerCase())
24+ return matches(item.title, word)
2525 })
2626 }
2727 }
2828 })
@@ -72,4 +72,8 @@
7272 } else {
7373 return fallback || ''
7474 }
7575 }
76+
77+function matches (text, startsWith) {
78+ return text.slice(0, startsWith.length).localeCompare(startsWith, 'default', {sensitivity: 'base'}) === 0
79+}
modules/profile/async/suggest.jsView
@@ -98,8 +98,7 @@
9898 return 'following'
9999 }
100100 }
101101
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
105104 }

Built with git-ssb-web