diff --git a/app/assets/javascripts/discourse/components/utilities.coffee b/app/assets/javascripts/discourse/components/utilities.coffee index 82f4c2304..e1d265064 100644 --- a/app/assets/javascripts/discourse/components/utilities.coffee +++ b/app/assets/javascripts/discourse/components/utilities.coffee @@ -46,7 +46,7 @@ Discourse.Utilities = emailValid: (email)-> # see: http://stackoverflow.com/questions/46155/validate-email-address-in-javascript - re = /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/ + re = /^[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/ re.test(email) selectedText: -> diff --git a/spec/javascripts/utilities_spec.js.coffee b/spec/javascripts/utilities_spec.js.coffee index 47b280f5a..cffca6315 100644 --- a/spec/javascripts/utilities_spec.js.coffee +++ b/spec/javascripts/utilities_spec.js.coffee @@ -80,3 +80,11 @@ describe "Discourse.Utilities", -> it "works with links that have underscores in them", -> expect(cook("http://en.wikipedia.org/wiki/Homicide:_Life_on_the_Street")).toBe("
") + + describe "emailValid", -> + + it "allows upper case in first part of emails", -> + expect(Discourse.Utilities.emailValid('Bob@example.com')).toBe(true) + + it "allows upper case in domain of emails", -> + expect(Discourse.Utilities.emailValid('bob@EXAMPLE.com')).toBe(true)