This repository was archived by the owner on Dec 30, 2022. It is now read-only.
Commit 61341a9 1 parent e78cacd commit 61341a9 Copy full SHA for 61341a9
File tree 2 files changed +42
-1
lines changed
2 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -333,4 +333,38 @@ describe('Store', () => {
333
333
334
334
expect ( store . _helper . getPage ( ) ) . toEqual ( 4 ) ;
335
335
} ) ;
336
+
337
+ test ( 'should allow to fetch sanitized results' , ( ) => {
338
+ const store = createStore ( ) ;
339
+ store . _helper . lastResults = {
340
+ hits : [
341
+ {
342
+ objectID : '1' ,
343
+ name : 'test' ,
344
+ _highlightResult : {
345
+ name : {
346
+ value :
347
+ "__ais-highlight__te__/ais-highlight__st<script>alert('test')</script>" ,
348
+ matchLevel : 'full' ,
349
+ } ,
350
+ } ,
351
+ } ,
352
+ ] ,
353
+ } ;
354
+
355
+ const results = store . results ;
356
+ expect ( results ) . toEqual ( [
357
+ {
358
+ objectID : '1' ,
359
+ name : 'test' ,
360
+ _highlightResult : {
361
+ name : {
362
+ value :
363
+ '<em>te</em>st<script>alert('test')</script>' ,
364
+ matchLevel : 'full' ,
365
+ } ,
366
+ } ,
367
+ } ,
368
+ ] ) ;
369
+ } ) ;
336
370
} ) ;
Original file line number Diff line number Diff line change 6
6
unserialize as unserializeHelper ,
7
7
} from './helper-serializer' ;
8
8
9
+ import sanitizeResults from './sanitize-results' ;
10
+
9
11
export const FACET_AND = 'and' ;
10
12
export const FACET_OR = 'or' ;
11
13
export const FACET_TREE = 'tree' ;
@@ -137,7 +139,12 @@ export class Store {
137
139
return [ ] ;
138
140
}
139
141
140
- return this . _helper . lastResults . hits ;
142
+ return sanitizeResults (
143
+ this . _helper . lastResults . hits ,
144
+ HIGHLIGHT_PRE_TAG ,
145
+ HIGHLIGHT_POST_TAG ,
146
+ 'em'
147
+ ) ;
141
148
}
142
149
143
150
get page ( ) {
You can’t perform that action at this time.
0 commit comments