Fixes reggae on user autocomplete

pull/1188/head
Marcelo Schmidt 10 years ago
parent 29bf75a785
commit 3b5acd9ab0
  1. 8
      client/views/app/messagePopup.coffee
  2. 4
      client/views/app/messagePopupConfig.coffee
  3. 2
      lib/RegExp.coffee

@ -44,13 +44,13 @@ Template.messagePopup.onCreated ->
template.suffix = val(template.data.suffix, ' ')
if template.triggerAnywhere is true
template.matchSelectorRegex = val(template.data.matchSelectorRegex, new RegExp "(?:^| )#{template.trigger}[^\s]*$")
template.matchSelectorRegex = val(template.data.matchSelectorRegex, new RegExp "(?:^| )#{template.trigger}[^\\s]*$")
else
template.matchSelectorRegex = val(template.data.matchSelectorRegex, new RegExp "(?:^)#{template.trigger}[^\s]*$")
template.matchSelectorRegex = val(template.data.matchSelectorRegex, new RegExp "(?:^)#{template.trigger}[^\\s]*$")
template.selectorRegex = val(template.data.selectorRegex, new RegExp "#{template.trigger}([^\s]*)$")
template.selectorRegex = val(template.data.selectorRegex, new RegExp "#{template.trigger}([^\\s]*)$")
template.replaceRegex = val(template.data.replaceRegex, new RegExp "#{template.trigger}[^\s]*$")
template.replaceRegex = val(template.data.replaceRegex, new RegExp "#{template.trigger}[^\\s]*$")
template.getValue = val template.data.getValue, (_id) -> return _id

@ -12,7 +12,7 @@ Template.messagePopupConfig.helpers
getInput: self.getInput
textFilterDelay: 200
getFilter: (collection, filter) ->
exp = new RegExp("#{filter}", 'i')
exp = new RegExp("#{RegExp.escape filter}", 'i')
template.userFilter.set filter
if template.userSubscription.ready()
items = filteredUsers.find({$or: [{username: exp}, {name: exp}]}, {limit: 5}).fetch()
@ -24,7 +24,7 @@ Template.messagePopupConfig.helpers
name: t 'Notify_all_in_this_room'
compatibility: 'channel group'
exp = new RegExp("(^|\\s)#{filter}", 'i')
exp = new RegExp("(^|\\s)#{RegExp.escape filter}", 'i')
if exp.test(all.username) or exp.test(all.compatibility)
items.unshift all
return items

@ -0,0 +1,2 @@
RegExp.escape = (s) ->
return s.replace /[-\/\\^$*+?.()|[\]{}]/g, '\\$&'
Loading…
Cancel
Save