From 941820ac88b28f43d017eb6057f9a566918842df Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Wed, 13 Feb 2013 14:30:00 -0500 Subject: [PATCH] Client-side email validation should allow capital letters --- .../javascripts/discourse/components/utilities.coffee | 2 +- spec/javascripts/utilities_spec.js.coffee | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/components/utilities.coffee b/app/assets/javascripts/discourse/components/utilities.coffee index 82f4c230475..e1d26506448 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 47b280f5a6d..cffca63157d 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("

http://en.wikipedia.org/wiki/Homicide:_Life_on_the_Street

") + + 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)