15
15
*
16
16
* @param {string } text Input text.
17
17
* @param {string } target Window (_blank|_self|_parent|_top) or named frame to open links in.
18
+ * @param {boolean } nofollow Add rel=nofollow to links.
18
19
* @returns {string } Html-linkified text.
19
20
*
20
21
* @usage
99
100
toBe('http://angularjs.org/');
100
101
expect(element(by.css('#linky-target a')).getAttribute('target')).toEqual('_blank');
101
102
});
103
+
104
+ it('should optionally add nofollow', function() {
105
+ expect(element(by.id('linky-target')).
106
+ element(by.binding("snippetWithTarget | linky:'_self':true")).getText()).
107
+ toBe('http://angularjs.org/');
108
+ expect(element(by.css('#linky-target a')).getAttribute('rel')).toEqual('nofollow');
109
+ });
102
110
</file>
103
111
</example>
104
112
*/
@@ -107,7 +115,7 @@ angular.module('ngSanitize').filter('linky', ['$sanitize', function($sanitize) {
107
115
/ ( ( f t p | h t t p s ? ) : \/ \/ | ( w w w \. ) | ( m a i l t o : ) ? [ A - Z a - z 0 - 9 . _ % + - ] + @ ) \S * [ ^ \s . ; , ( ) { } < > " \u201d \u2019 ] / i,
108
116
MAILTO_REGEXP = / ^ m a i l t o : / i;
109
117
110
- return function ( text , target ) {
118
+ return function ( text , target , nofollow ) {
111
119
if ( ! text ) return text ;
112
120
var match ;
113
121
var raw = text ;
@@ -143,6 +151,9 @@ angular.module('ngSanitize').filter('linky', ['$sanitize', function($sanitize) {
143
151
target ,
144
152
'" ' ) ;
145
153
}
154
+ if ( nofollow ) {
155
+ html . push ( 'rel="nofollow" ' ) ;
156
+ }
146
157
html . push ( 'href="' ,
147
158
url . replace ( / " / g, '"' ) ,
148
159
'">' ) ;
0 commit comments