Skip to content

Commit 5cc2559

Browse files
author
Warren Rumak
committed
fix for issue #76, added ", ", &#39 to list of common HTML chararacter entities
1 parent 07038c7 commit 5cc2559

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/Autolinker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ Autolinker.prototype = {
185185
*
186186
* Ignoring & as it could be part of a query string -- handling it separately.
187187
*/
188-
htmlCharacterEntitiesRegex: /( | |<|<|>|>)/gi,
188+
htmlCharacterEntitiesRegex: /( | |<|<|>|>|"|"|')/gi,
189189

190190
/**
191191
* @private

tests/AutolinkerSpec.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,6 @@ describe( "Autolinker", function() {
993993
expect( result ).toBe('<p>Joe went to <a href="http://yahoo.com">yahoo.com</a>&nbsp;and <a href="http://google.com">google.com</a>&nbsp;today</p>');
994994
} );
995995

996-
997996
it( "should handle HTML entities like &nbsp; within a non-autolinked part of a text node, properly appending it to the output", function() {
998997
var html = "Joe went to yahoo.com and used HTML&nbsp;entities like &gt; and &lt; google.com";
999998

@@ -1009,6 +1008,13 @@ describe( "Autolinker", function() {
10091008
expect( result ).toBe( '<p>Joe went to <a href="http://example.com?arg=1&arg=2&arg=3">example.com?arg=1&amp;arg=2&amp;arg=3</a></p>' );
10101009
} );
10111010

1011+
it( "should handle a URL inside an HTML-encoded anchor tag (Issue #76)", function() {
1012+
var html = "Joe learned about anchor tags on the &lt;a href=&quot;http://www.w3schools.com/aaa&quot;&gt;W3SCHOOLS&lt;/a&gt; site ...";
1013+
var tobe = "Joe learned about anchor tags on the &lt;a href=&quot;<a href=\"http://www.w3schools.com/aaa\">w3schools.com/aaa</a>&quot;&gt;W3SCHOOLS&lt;/a&gt; site ...";
1014+
1015+
var result = autolinker.link( html );
1016+
expect( result ).toBe( tobe );
1017+
});
10121018
} );
10131019

10141020

0 commit comments

Comments
 (0)