Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 8dc09e6

Browse files
Conny Sjöblompetebacondarwin
Conny Sjöblom
authored andcommitted
fix(linky): allow case insensitive scheme detection
Closes #12073 Closes #12073
1 parent 799353c commit 8dc09e6

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/ngSanitize/filter/linky.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@
104104
*/
105105
angular.module('ngSanitize').filter('linky', ['$sanitize', function($sanitize) {
106106
var LINKY_URL_REGEXP =
107-
/((ftp|https?):\/\/|(www\.)|(mailto:)?[A-Za-z0-9._%+-]+@)\S*[^\s.;,(){}<>"]/,
108-
MAILTO_REGEXP = /^mailto:/;
107+
/((ftp|https?):\/\/|(www\.)|(mailto:)?[A-Za-z0-9._%+-]+@)\S*[^\s.;,(){}<>"]/i,
108+
MAILTO_REGEXP = /^mailto:/i;
109109

110110
return function(text, target) {
111111
if (!text) return text;

test/ngSanitize/filter/linkySpec.js

+9
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ describe('linky', function() {
2020
expect(linky(undefined)).not.toBeDefined();
2121
});
2222

23+
it('should be case-insensitive', function() {
24+
expect(linky('WWW.example.com')).toEqual('<a href="http://WWW.example.com">WWW.example.com</a>');
25+
expect(linky('WWW.EXAMPLE.COM')).toEqual('<a href="http://WWW.EXAMPLE.COM">WWW.EXAMPLE.COM</a>');
26+
expect(linky('HTTP://www.example.com')).toEqual('<a href="HTTP://www.example.com">HTTP://www.example.com</a>');
27+
expect(linky('HTTP://example.com')).toEqual('<a href="HTTP://example.com">HTTP://example.com</a>');
28+
expect(linky('HTTPS://www.example.com')).toEqual('<a href="HTTPS://www.example.com">HTTPS://www.example.com</a>');
29+
expect(linky('HTTPS://example.com')).toEqual('<a href="HTTPS://example.com">HTTPS://example.com</a>');
30+
});
31+
2332
it('should handle www.', function() {
2433
expect(linky('www.example.com')).toEqual('<a href="http://www.example.com">www.example.com</a>');
2534
});

0 commit comments

Comments
 (0)