Skip to content

Commit 4e20c37

Browse files
author
김부승
committed
Rollback reorder call methods and add equal subsequence exception in 'compactMatches' method
1 parent 72ff026 commit 4e20c37

14 files changed

+91
-40
lines changed

dist/Autolinker.js

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -630,17 +630,18 @@ Autolinker.prototype = {
630630
}
631631
}
632632

633-
// After we have found all matches, remove matches for match types that have been turned
634-
// off. We needed to have all match types turned on initially so that
635-
// things like hashtags could be filtered out if they were really just
636-
// part of a URL match (for instance, as a named anchor).
637-
matches = this.removeUnwantedMatches( matches );
638633

639-
// And finally, remove subsequent matches that
634+
// After we have found all matches, remove subsequent matches that
640635
// overlap with a previous match. This can happen for instance with URLs,
641636
// where the url 'google.com/#link' would match '#link' as a hashtag.
642637
matches = this.compactMatches( matches );
643638

639+
// And finally, remove matches for match types that have been turned
640+
// off. We needed to have all match types turned on initially so that
641+
// things like hashtags could be filtered out if they were really just
642+
// part of a URL match (for instance, as a named anchor).
643+
matches = this.removeUnwantedMatches( matches );
644+
644645
return matches;
645646
},
646647

@@ -660,11 +661,22 @@ Autolinker.prototype = {
660661

661662
for( var i = 0; i < matches.length - 1; i++ ) {
662663
var match = matches[ i ],
663-
endIdx = match.getOffset() + match.getMatchedText().length;
664+
offset = match.getOffset(),
665+
matchedTextLength = match.getMatchedText().length,
666+
endIdx = offset + matchedTextLength;
667+
668+
if( i + 1 < matches.length ) {
669+
// Remove subsequent matches that equal offset with current match
670+
if( matches[ i + 1 ].getOffset() === offset ) {
671+
var removeIdx = matches[ i + 1 ].getMatchedText().length > matchedTextLength ? i : i + 1;
672+
matches.splice( removeIdx, 1 );
673+
continue;
674+
}
664675

665-
// Remove subsequent matches that overlap with the current match
666-
while( i + 1 < matches.length && matches[ i + 1 ].getOffset() <= endIdx ) {
667-
matches.splice( i + 1, 1 );
676+
// Remove subsequent matches that overlap with the current match
677+
if( matches[ i + 1 ].getOffset() <= endIdx ) {
678+
matches.splice( i + 1, 1 );
679+
}
668680
}
669681
}
670682

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.

docs/api/data-1df28a367878e4e8fc26f668c464fdb1.js renamed to docs/api/data-97897bf9ffc99e3f2efe9ad3da7e2b84.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/api/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<link rel="stylesheet" href="styles-3eba09980fa05ead185cb17d9c0deb0f.css" type="text/css" />
1414

1515
<script type="text/javascript" src="extjs/ext-all.js"></script>
16-
<script type="text/javascript" src="data-1df28a367878e4e8fc26f668c464fdb1.js"></script>
16+
<script type="text/javascript" src="data-97897bf9ffc99e3f2efe9ad3da7e2b84.js"></script>
1717

1818
<script type="text/javascript" src="app-0c945a27f43452df695771ddb60b3d14.js"></script>
1919

@@ -82,7 +82,7 @@ <h3>Others...</h3>
8282

8383

8484

85-
<div id='footer-content' style='display: none'>Generated on Thu 02 Mar 2017 22:30:00 by <a href='https://github.com/senchalabs/jsduck'>JSDuck</a> 5.3.4.</div>
85+
<div id='footer-content' style='display: none'>Generated on Thu 06 Apr 2017 12:37:56 by <a href='https://github.com/senchalabs/jsduck'>JSDuck</a> 5.3.4.</div>
8686

8787

8888

docs/api/output/Autolinker.matcher.Hashtag.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/api/output/Autolinker.matcher.Matcher.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/api/output/Autolinker.matcher.Url.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)