Skip to content

Commit

Permalink
Escape regex meta chars
Browse files Browse the repository at this point in the history
Fixes Raku#1442
  • Loading branch information
zoffixznet committed Aug 8, 2017
1 parent 90ff6a5 commit 38846bc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion template/search_template.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ $(function(){
this.widget().menu( "option", "items", "> :not(.ui-autocomplete-category)" );
},
_renderItem: function( ul, item) {
var regex = new RegExp('(' + current_search + ')', 'ig');
var regex = new RegExp('('
+ current_search.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')
+ ')', 'ig');
var text = item.label.replace(regex, '<b>$1</b>');
return $( "<li>" )
.append( $( "<div>" ).html(text) )
Expand Down

0 comments on commit 38846bc

Please sign in to comment.