diff --git a/src/matcher/url-matcher.ts b/src/matcher/url-matcher.ts index ea19c560..bf6bc1c1 100644 --- a/src/matcher/url-matcher.ts +++ b/src/matcher/url-matcher.ts @@ -76,7 +76,7 @@ export class UrlMatcher extends Matcher { // Allow optional path, query string, and hash anchor, not ending in the following characters: "?!:,.;" // http://blog.codinghorror.com/the-problem-with-urls/ - urlSuffixRegex = new RegExp( '[/?#](?:[' + alphaNumericAndMarksCharsStr + '\\-+&@#/%=~_()|\'$*\\[\\]?!:,.;\u2713]*[' + alphaNumericAndMarksCharsStr + '\\-+&@#/%=~_()|\'$*\\[\\]\u2713])?' ); + urlSuffixRegex = new RegExp( '[/?#](?:[' + alphaNumericAndMarksCharsStr + '\\-^+&@#/%=~_()|\'$*\\[\\]?!:,.;\u2713]*[' + alphaNumericAndMarksCharsStr + '\\-^+&@#/%=~_()|\'$*\\[\\]\u2713])?' ); return new RegExp( [ '(?:', // parens to cover match for scheme (optional), and domain diff --git a/tests/matcher/url-matcher.spec.ts b/tests/matcher/url-matcher.spec.ts index 7852d666..e8e3ff26 100644 --- a/tests/matcher/url-matcher.spec.ts +++ b/tests/matcher/url-matcher.spec.ts @@ -133,6 +133,29 @@ describe( "Autolinker.matcher.Url", function() { expect( othermatches.length ).toBe( 1 ); }); + it( 'should match the entire URL with a single ^ in a parameter', function() { + let matches = matcher.parseMatches( 'https://google.fr/path?parameter=^value12345' ); + let othermatches = matcher.parseMatches( 'https://google.fr/path?parameter=value^12345' ); + + + expect( matches.length ).toBe( 1 ); + MatchChecker.expectUrlMatch( matches[ 0 ], 'https://google.fr/path?parameter=^value12345', 0 ); + + + expect( othermatches.length ).toBe( 1 ); + MatchChecker.expectUrlMatch( othermatches[ 0 ], 'https://google.fr/path?parameter=value^12345', 0 ); + }); + + it( 'should match the entire URL with multiple ^ in a parameter', function() { + let matches = matcher.parseMatches( 'https://google.fr/path?parameter=^value1¶meter2=value^2' ); + + + + expect( matches.length ).toBe( 1 ); + MatchChecker.expectUrlMatch( matches[ 0 ], 'https://google.fr/path?parameter=^value1¶meter2=value^2' , 0 ); + }); + + it( 'should match katakana with dakuten characters (symbol with combining mark - two unicode characters)', function() { var matches = matcher.parseMatches( 'https://website.com/files/name-ボ.pdf' );