File tree Expand file tree Collapse file tree 2 files changed +26
-5
lines changed Expand file tree Collapse file tree 2 files changed +26
-5
lines changed Original file line number Diff line number Diff line change @@ -4,16 +4,20 @@ var escape = Ember.Handlebars.Utils.escapeExpression;
4
4
5
5
function formatEmail ( email ) {
6
6
var formatted = email . match ( / ^ ( .* ?) \s * (?: < ( .* ) > ) ? $ / ) ;
7
- var email = "" ;
7
+ var ret = "" ;
8
8
9
- email += escape ( formatted [ 1 ] ) ;
9
+ ret += escape ( formatted [ 1 ] ) ;
10
10
11
11
if ( formatted [ 2 ] ) {
12
- email = "<a href='mailto:" + escape ( formatted [ 2 ] ) + "'>" + email + "</a>" ;
12
+ ret = "<a href='mailto:" + escape ( formatted [ 2 ] ) + "'>" + ret + "</a>" ;
13
13
}
14
14
15
- console . log ( email ) ;
16
- return email . htmlSafe ( ) ;
15
+ return ret . htmlSafe ( ) ;
17
16
}
18
17
18
+
19
+ export {
20
+ formatEmail
21
+ } ;
22
+
19
23
export default Ember . Handlebars . makeBoundHelper ( formatEmail ) ;
Original file line number Diff line number Diff line change
1
+ import {
2
+ formatEmail
3
+ } from 'cargo/helpers/format-email' ;
4
+
5
+ module ( 'FormatEmailHelper' ) ;
6
+
7
+ // Replace this with your real tests.
8
+ test ( 'it works' , function ( assert ) {
9
+ assert . equal ( formatEmail ( 'foo' ) , 'foo' ) ;
10
+ assert . equal ( formatEmail ( 'foo <foo@bar.com>' ) . toString ( ) ,
11
+ "<a href='mailto:foo@bar.com'>foo</a>" ) ;
12
+ assert . equal ( formatEmail ( '<script></script> <foo@bar.com>' ) . toString ( ) ,
13
+ "<a href='mailto:script></script> <foo@bar.com'></a>" ) ;
14
+ assert . equal ( formatEmail ( '' ) . toString ( ) , '' ) ;
15
+ assert . equal ( formatEmail ( 'test <foo' ) . toString ( ) , 'test <foo' ) ;
16
+ } ) ;
17
+
You can’t perform that action at this time.
0 commit comments