OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 cr.define('options.accounts', function() { | 5 cr.define('options.accounts', function() { |
6 /** | 6 /** |
7 * Email alias only, assuming it's a gmail address. | 7 * Email alias only, assuming it's a gmail address. |
8 * e.g. 'john' | 8 * e.g. 'john' |
9 * {name: 'john', email: 'john@gmail.com'} | 9 * {name: 'john', email: 'john@gmail.com'} |
10 * @const | 10 * @const |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 * IMA (Internationalized Email Address). We take only the following chars | 60 * IMA (Internationalized Email Address). We take only the following chars |
61 * as valid for an email alias (aka local-part): | 61 * as valid for an email alias (aka local-part): |
62 * - Letters: a–z, A–Z | 62 * - Letters: a–z, A–Z |
63 * - Digits: 0-9 | 63 * - Digits: 0-9 |
64 * - Characters: ! # $ % & ' * + - / = ? ^ _ ` { | } ~ | 64 * - Characters: ! # $ % & ' * + - / = ? ^ _ ` { | } ~ |
65 * - Dot: . (Note that we did not cover the cases that dot should not | 65 * - Dot: . (Note that we did not cover the cases that dot should not |
66 * appear as first or last character and should not appear two or | 66 * appear as first or last character and should not appear two or |
67 * more times in a row.) | 67 * more times in a row.) |
68 * | 68 * |
69 * @param {string} str A string to parse. | 69 * @param {string} str A string to parse. |
70 * @return {{name: string, email: string}} User info parsed from the string. | 70 * @return {?{name: string, email: string}} User info parsed from the |
| 71 * string. |
71 */ | 72 */ |
72 parse: function(str) { | 73 parse: function(str) { |
73 /** @const */ var format1 = new RegExp(format1String); | 74 /** @const */ var format1 = new RegExp(format1String); |
74 /** @const */ var format2 = new RegExp(format2String); | 75 /** @const */ var format2 = new RegExp(format2String); |
75 /** @const */ var format3 = new RegExp(format3String); | 76 /** @const */ var format3 = new RegExp(format3String); |
76 | 77 |
77 var matches = format1.exec(str); | 78 var matches = format1.exec(str); |
78 if (matches) { | 79 if (matches) { |
79 return { | 80 return { |
80 name: matches[1], | 81 name: matches[1], |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 e.stopPropagation(); | 120 e.stopPropagation(); |
120 } | 121 } |
121 } | 122 } |
122 }; | 123 }; |
123 | 124 |
124 return { | 125 return { |
125 UserNameEdit: UserNameEdit | 126 UserNameEdit: UserNameEdit |
126 }; | 127 }; |
127 }); | 128 }); |
128 | 129 |
OLD | NEW |