This repository was archived by the owner on Dec 30, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +42
-1
lines changed
Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -333,4 +333,38 @@ describe('Store', () => {
333333
334334 expect ( store . _helper . getPage ( ) ) . toEqual ( 4 ) ;
335335 } ) ;
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+ } ) ;
336370} ) ;
Original file line number Diff line number Diff line change 66 unserialize as unserializeHelper ,
77} from './helper-serializer' ;
88
9+ import sanitizeResults from './sanitize-results' ;
10+
911export const FACET_AND = 'and' ;
1012export const FACET_OR = 'or' ;
1113export const FACET_TREE = 'tree' ;
@@ -137,7 +139,12 @@ export class Store {
137139 return [ ] ;
138140 }
139141
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+ ) ;
141148 }
142149
143150 get page ( ) {
You can’t perform that action at this time.
0 commit comments