File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -84,11 +84,11 @@ function _groups(tokens, phrases) {
84
84
// key is a single word token (the first word in
85
85
// the phrase) and the values is an array of
86
86
// phrases which contain that word.
87
- const index = { } ;
87
+ const index = Object . create ( null ) ;
88
88
phrases . forEach ( phrase => {
89
89
const words = phrase . split ( / \s + / ) ;
90
90
const firstWord = words [ 0 ] ;
91
- if ( ! index . hasOwnProperty ( firstWord ) ) {
91
+ if ( ! index [ firstWord ] ) {
92
92
index [ firstWord ] = [ ] ;
93
93
}
94
94
index [ firstWord ] . push ( words ) ;
Original file line number Diff line number Diff line change @@ -177,6 +177,17 @@ module.exports._groups = function(test, common) {
177
177
t . deepEqual ( tokenize . _groups ( tokens , phrases ) , expected ) ;
178
178
t . end ( ) ;
179
179
} ) ;
180
+
181
+ // https://github.com/pelias/placeholder/issues/231
182
+ test ( '_groups "constructor"' , function ( t ) {
183
+
184
+ const tokens = [ 'constructor' ] ;
185
+ const phrases = [ ] ;
186
+ const expected = [ ] ;
187
+
188
+ t . deepEqual ( tokenize . _groups ( tokens , phrases ) , expected ) ;
189
+ t . end ( ) ;
190
+ } ) ;
180
191
} ;
181
192
182
193
//
You can’t perform that action at this time.
0 commit comments