FIX: username mentions weren't working when immediately followed by a dot

This commit is contained in:
Régis Hanol 2016-01-07 22:23:01 +01:00
parent 850838147a
commit c5f9ae0de1
3 changed files with 6 additions and 6 deletions
app

View file

@ -4,7 +4,7 @@
**/ **/
Discourse.Dialect.inlineRegexp({ Discourse.Dialect.inlineRegexp({
start: '#', start: '#',
matcher: /^#([\w-]{1,50})/, matcher: /^#([\w-]{1,50})/i,
spaceOrTagBoundary: true, spaceOrTagBoundary: true,
emitter: function(matches) { emitter: function(matches) {

View file

@ -7,11 +7,11 @@ Discourse.Dialect.inlineRegexp({
start: '@', start: '@',
// NOTE: since we can't use SiteSettings here (they loads later in process) // NOTE: since we can't use SiteSettings here (they loads later in process)
// we are being less strict to account for more cases than allowed // we are being less strict to account for more cases than allowed
matcher: /^@([\w.-]+)/, matcher: /^@(\w[\w.-]{0,59})\b/i,
wordBoundary: true, wordBoundary: true,
emitter: function(matches) { emitter: function(matches) {
var mention = matches[0], var mention = matches[0].trim(),
name = matches[1], name = matches[1],
mentionLookup = this.dialect.options.mentionLookup; mentionLookup = this.dialect.options.mentionLookup;

View file

@ -61,21 +61,21 @@ class UsernameValidator
def username_char_valid? def username_char_valid?
return unless errors.empty? return unless errors.empty?
if username =~ /[^A-Za-z0-9_\.\-]/ if username =~ /[^\w.-]/
self.errors << I18n.t(:'user.username.characters') self.errors << I18n.t(:'user.username.characters')
end end
end end
def username_first_char_valid? def username_first_char_valid?
return unless errors.empty? return unless errors.empty?
if username[0] =~ /[^A-Za-z0-9_]/ if username[0] =~ /[^\w]/
self.errors << I18n.t(:'user.username.must_begin_with_alphanumeric') self.errors << I18n.t(:'user.username.must_begin_with_alphanumeric')
end end
end end
def username_last_char_valid? def username_last_char_valid?
return unless errors.empty? return unless errors.empty?
if username[-1] =~ /[^A-Za-z0-9_]/ if username[-1] =~ /[^\w]/
self.errors << I18n.t(:'user.username.must_end_with_alphanumeric') self.errors << I18n.t(:'user.username.must_end_with_alphanumeric')
end end
end end