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

View File

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

View File

@ -7,11 +7,11 @@ Discourse.Dialect.inlineRegexp({
start: '@',
// 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
matcher: /^@([\w.-]+)/,
matcher: /^@(\w[\w.-]{0,59})\b/i,
wordBoundary: true,
emitter: function(matches) {
var mention = matches[0],
var mention = matches[0].trim(),
name = matches[1],
mentionLookup = this.dialect.options.mentionLookup;

View File

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