Skip to content

Commit cbe10cd

Browse files
committed
Add info about v0.9.2, and tweak a little formatting / reorder one of the unit tests.
1 parent 41e2003 commit cbe10cd

File tree

6 files changed

+22
-9
lines changed

6 files changed

+22
-9
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ autolinker.link( "Go to www.google.com" );
148148

149149
## Changelog:
150150

151+
### 0.9.2
152+
153+
- Fixed an issue with nested tags within an existing <a> tag, where the nested tags' inner text would be accidentally
154+
removed from the output (thanks [@mjsabin01](https://github.com/mjsabin01))
155+
151156
### 0.9.1
152157

153158
- Added a patch to attempt to better handle extraneous </a> tags in the input string if any exist. This is for when the

dist/Autolinker.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
22
* autolinker
3-
* 0.9.1
3+
* 0.9.2
44
*
55
* Copyright(c) 2014 Gregory Jacobs <[email protected]>
66
* MIT Licensed. http://www.opensource.org/licenses/mit-license.php
@@ -307,6 +307,11 @@
307307

308308
} else if( anchorTagStackCount === 0 ) { // not within an anchor tag, link the "in between" text
309309
resultHtml.push( this.processTextNode( inBetweenTagsText ) );
310+
311+
} else {
312+
// if we have a tag that is in between anchor tags (ex: <a href="..."><b>google.com</b></a>),
313+
// just append the inner text
314+
resultHtml.push( inBetweenTagsText );
310315
}
311316

312317
resultHtml.push( tagText ); // now add the text of the tag itself verbatim

dist/Autolinker.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "autolinker",
3-
"version": "0.9.1",
3+
"version": "0.9.2",
44
"description": "Simple utility to automatically link the URLs, email addresses, and Twitter handles in a given block of text/HTML",
55
"main": "dist/Autolinker.js",
66
"directories": {

src/Autolinker.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,10 @@
298298

299299
} else if( anchorTagStackCount === 0 ) { // not within an anchor tag, link the "in between" text
300300
resultHtml.push( this.processTextNode( inBetweenTagsText ) );
301+
301302
} else {
302-
// if we have a tag that is between anchor tags, just enter the text
303+
// if we have a tag that is in between anchor tags (ex: <a href="..."><b>google.com</b></a>),
304+
// just append the inner text
303305
resultHtml.push( inBetweenTagsText );
304306
}
305307

tests/AutolinkerSpec.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,15 +282,16 @@ describe( "Autolinker", function() {
282282
} );
283283

284284

285-
it( "should attempt to handle some invalid HTML markup relating to <a> tags, esp if there are extraneous closing </a> tags", function() {
286-
var html = '</a><a href="http://google.com">google.com</a>';
285+
it( "should properly handle HTML markup + text nodes that are nested within <a> tags", function() {
286+
var html = '<a href="http://google.com"><b>google.com</b></a>';
287287

288288
var result = autolinker.link( html );
289289
expect( result ).toBe( html );
290290
} );
291291

292-
it( "should handle HTML markup relating to <a> tagswhen formatting is applied", function() {
293-
var html = '</a><a href="http://google.com"><b>google.com</b></a>';
292+
293+
it( "should attempt to handle some invalid HTML markup relating to <a> tags, esp if there are extraneous closing </a> tags", function() {
294+
var html = '</a><a href="http://google.com">google.com</a>';
294295

295296
var result = autolinker.link( html );
296297
expect( result ).toBe( html );

0 commit comments

Comments
 (0)