2
0
mirror of https://github.com/tenrok/bootstrap.git synced 2026-06-08 17:22:31 +03:00

typeahead should escape regexp special chars

This commit is contained in:
Jacob Thornton
2012-03-19 15:33:28 -07:00
parent bf59220b87
commit 83a7a69893
2 changed files with 18 additions and 1 deletions
+2 -1
View File
@@ -109,7 +109,8 @@
}
, highlighter: function (item) {
return item.replace(new RegExp('(' + this.query + ')', 'ig'), function ($1, match) {
var query = this.query.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')
return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
return '<strong>' + match + '</strong>'
})
}