Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/autolinker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -745,8 +745,8 @@ export default class Autolinker { // NOTE: must be 'export default' here for UM
private compactMatches( matches: Match[] ) {
// First, the matches need to be sorted in order of offset
matches.sort( function( a, b ) { return a.getOffset() - b.getOffset(); } );

for( let i = 0; i < matches.length - 1; i++ ) {
let i = 0;
while(i < matches.length - 1) {
let match = matches[ i ],
offset = match.getOffset(),
matchedTextLength = match.getMatchedText().length,
Expand All @@ -763,8 +763,10 @@ export default class Autolinker { // NOTE: must be 'export default' here for UM
// Remove subsequent matches that overlap with the current match
if( matches[ i + 1 ].getOffset() < endIdx ) {
matches.splice( i + 1, 1 );
continue;
}
}
i++;
}

return matches;
Expand Down
9 changes: 9 additions & 0 deletions tests/autolinker-url.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1073,4 +1073,13 @@ describe( "Autolinker Url Matching -", () => {

} );

describe( "emails in URL", function() {
it( "should autolink a url with multiple email in the query string", function() {
const result = autolinker.link("https://example.com/api/path?apikey={API_Key}&message=Test&[email protected]&department=someid123&subject=Some_Subject&[email protected]&is_html_message=Y");

expect( result ).toBe( '<a href="https://example.com/api/path?apikey={API_Key}&message=Test&[email protected]&department=someid123&subject=Some_Subject&[email protected]&is_html_message=Y">example.com/api/path?apikey={API_Key}&message=Test&[email protected]&department=someid123&subject=Some_Subject&[email protected]&is_html_message=Y</a>' );
} );

} );

} );