Skip to content

Add support for the character ^ to be used in URL parameters #267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/matcher/url-matcher.ts
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions tests/matcher/url-matcher.spec.ts
Original file line number Diff line number Diff line change
@@ -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&parameter2=value^2' );



expect( matches.length ).toBe( 1 );
MatchChecker.expectUrlMatch( matches[ 0 ], 'https://google.fr/path?parameter=^value1&parameter2=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' );