summaryrefslogtreecommitdiff
path: root/web-ui
diff options
context:
space:
mode:
authorGiovane <giovaneliberato@gmail.com>2015-10-26 17:01:18 -0200
committerGiovane <giovaneliberato@gmail.com>2015-10-26 17:01:39 -0200
commit2981e337140f67c1d555741fa5f9f663c651f26f (patch)
tree2f5e9f240177721eba4e39e4efb8d6df9d67ac0c /web-ui
parent800f211937e4e09a02779c20c6c79ce6edd833f1 (diff)
Add incomplete email domain verification on compose box.
Diffstat (limited to 'web-ui')
-rw-r--r--web-ui/app/js/mail_view/ui/recipients/recipients_input.js30
-rw-r--r--web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js19
2 files changed, 33 insertions, 16 deletions
diff --git a/web-ui/app/js/mail_view/ui/recipients/recipients_input.js b/web-ui/app/js/mail_view/ui/recipients/recipients_input.js
index 3e80b49e..2c3a4604 100644
--- a/web-ui/app/js/mail_view/ui/recipients/recipients_input.js
+++ b/web-ui/app/js/mail_view/ui/recipients/recipients_input.js
@@ -42,8 +42,8 @@ define([
},
self;
- var simpleAddressMatch = /[^<\w,;]?([^\s<;,]+@[^\s>;,]+)/;
- var canonicalAddressMatch = /([^,;\s][^,;@]+<[^\s;,]+@[^\s;,]+>)/;
+ var simpleAddressMatch = /[^<\w,;]?([^\s<;,]+@\w+\.[^\s>;,]+)/;
+ var canonicalAddressMatch = /([^,;\s][^,;@]+<[^\s;,]+@\w+\.[^\s;,]+>)/;
var emailAddressMatch = new RegExp([simpleAddressMatch.source, '|', canonicalAddressMatch.source].join(''), 'g');
var extractContactNames = function (response) {
@@ -112,31 +112,31 @@ define([
this.recipientSelected = function (event, data) {
var value = (data && data.value) || this.$node.val();
- var that = this;
-
- function triggerEventForEach(addresses, event) {
- _.each(addresses, function(address) {
- if (!_.isEmpty(address.trim())) {
- that.trigger(that.$node, event, { name: that.attr.name, address: address.trim() });
- }
- });
- }
var validAddresses = this.extractValidAddresses(value);
var invalidAddresses = this.extractInvalidAddresses(value);
- triggerEventForEach(validAddresses, events.ui.recipients.entered);
- triggerEventForEach(invalidAddresses, events.ui.recipients.enteredInvalid);
+ this.triggerEventForEach(validAddresses, events.ui.recipients.entered);
+ this.triggerEventForEach(invalidAddresses, events.ui.recipients.enteredInvalid);
reset(this.$node);
};
- this.extractValidAddresses = function(rawAddresses) {
+ this.triggerEventForEach = function (addresses, event) {
+ var that = this;
+ _.each(addresses, function(address) {
+ if (!_.isEmpty(address.trim())) {
+ that.trigger(that.$node, event, { name: that.attr.name, address: address.trim() });
+ }
+ });
+ };
+
+ this.extractValidAddresses = function(rawAddresses) {
return rawAddresses.match(emailAddressMatch);
};
this.extractInvalidAddresses = function(rawAddresses) {
- return rawAddresses.replace(emailAddressMatch, '').split(/[ ,;]/);
+ return rawAddresses.replace(emailAddressMatch, '').split(/[,;]/);
};
this.init = function () {
diff --git a/web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js b/web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js
index 29194ee8..c0b3d22f 100644
--- a/web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js
+++ b/web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js
@@ -34,7 +34,7 @@ describeComponent('mail_view/ui/recipients/recipients_input',function () {
expect(addressEnteredEvent).not.toHaveBeenTriggeredOnAndWith(this, { name: 'to', address: '' });
});
- it('wont add address if shift key is pressed together: ' + keycode[1], function () {
+ it('won`t add address if shift key is pressed together: ' + keycode[1], function () {
var addressEnteredEvent = spyOnEvent(this.$node, Pixelated.events.ui.recipients.entered);
var enterAddressKeyPressEvent = $.Event('keydown', { which: keycode[0], shiftKey: true });
@@ -186,5 +186,22 @@ describeComponent('mail_view/ui/recipients/recipients_input',function () {
expect(addressEnteredEvent.calls[0].data).toEqual({name: 'to', address: 'email@example.com'});
});
+ it('displays it as an invalid address token when domain isn`t complete', function() {
+ this.$node.val('email@example');
+ this.$node.trigger(blurEvent);
+
+ expect(blurEvent.preventDefault).toHaveBeenCalled();
+ expect(invalidAddressEnteredEvent.calls[0].data).toEqual({name: 'to', address: 'email@example'});
+ });
+
+ it('displays it as an invalid address token when cannonical email domain isn`t complete', function() {
+ this.$node.val('Invalid <email@example>');
+ this.$node.trigger(blurEvent);
+
+ expect(blurEvent.preventDefault).toHaveBeenCalled();
+ expect(invalidAddressEnteredEvent.calls[0].data).toEqual({name: 'to', address: 'Invalid <email@example>'});
+ });
+
+
});
});