| @@ -112,6 +112,25 @@ class app.Searcher · 111 unmodified lines |
| 112 | max_results: app.config.max_results | 112 | max_results: app.config.max_results |
| 113 | fuzzy_min_length: 3 | 113 | fuzzy_min_length: 3 |
| 114 | | 114 | |
| | 115 | SEPARATORS_REGEXP = /\:?\ |#|::|->/g |
| | 116 | PARANTHESES_REGEXP = /\(.*?\)$/ |
| | 117 | EVENT_REGEXP = /\ event$/ |
| | 118 | DOT_REGEXP = /\.+/g |
| | 119 | WHITESPACE_REGEXP = /\s/g |
| | 120 | |
| | 121 | EMPTY_STRING = '' |
| | 122 | ELLIPSIS = '...' |
| | 123 | |
| | 124 | @normalizeString: (string) -> |
| | 125 | string |
| | 126 | .toLowerCase() |
| | 127 | .replace ELLIPSIS, EMPTY_STRING |
| | 128 | .replace EVENT_REGEXP, EMPTY_STRING |
| | 129 | .replace SEPARATORS_REGEXP, SEPARATOR |
| | 130 | .replace DOT_REGEXP, SEPARATOR |
| | 131 | .replace PARANTHESES_REGEXP, EMPTY_STRING |
| | 132 | .replace WHITESPACE_REGEXP, EMPTY_STRING |
| | 133 | |
| 115 | constructor: (options = {}) -> | 134 | constructor: (options = {}) -> |
| 116 | @options = $.extend {}, DEFAULTS, options | 135 | @options = $.extend {}, DEFAULTS, options |
| 117 | | 136 | |
| @@ -127,7 +146,7 @@ class app.Searcher · 9 unmodified lines |
| 127 | return | 146 | return |
| 128 | | 147 | |
| 129 | setup: -> | 148 | setup: -> |
| 130 | query = @query = @normalizeQuery(@query) | 149 | query = @query = @constructor.normalizeString(@query) |
| 131 | queryLength = query.length | 150 | queryLength = query.length |
| 132 | @dataLength = @data.length | 151 | @dataLength = @data.length |
| 133 | @matchers = [exactMatch] | 152 | @matchers = [exactMatch] |
| @@ -231,9 +250,6 @@ class app.Searcher · 97 unmodified lines |
| 231 | delay: (fn) -> | 250 | delay: (fn) -> |
| 232 | @timeout = setTimeout(fn, 1) | 251 | @timeout = setTimeout(fn, 1) |
| 233 | | 252 | |
| 234 | normalizeQuery: (string) -> | | |
| 235 | string.replace(/\s/g, '').toLowerCase() | | |
| 236 | | | |
| 237 | queryToFuzzyRegexp: (string) -> | 253 | queryToFuzzyRegexp: (string) -> |
| 238 | chars = string.split '' | 254 | chars = string.split '' |
| 239 | chars[i] = $.escapeRegexp(char) for char, i in chars | 255 | chars[i] = $.escapeRegexp(char) for char, i in chars |