Skip to content

Commit

Permalink
Don't allow apostrophe in URLs (#499)
Browse files Browse the repository at this point in the history
Fixes #488, should end URL if encountered.
  • Loading branch information
nfrasser authored Dec 4, 2024
1 parent b72c682 commit a7629c2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 0 additions & 1 deletion packages/linkifyjs/src/parser.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export function init({ groups }) {
// but cannot be the very last characters
// Characters that cannot appear in the URL at all should be excluded
const qsNonAccepting = [
tk.APOSTROPHE,
tk.COLON,
tk.COMMA,
tk.DOT,
Expand Down
9 changes: 7 additions & 2 deletions test/spec/linkifyjs/parser.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,9 @@ const tests = [
],
['"https://surrounded.by.quotes/"', [Text, Url, Text], ['"', 'https://surrounded.by.quotes/', '"']],
[
"More weird character in http://facebook.com/#aZ?/:@-._~!$&'()*+,;= that Url",
'More weird character in http://facebook.com/#aZ?/:@-._~!$&()*+,;= that Url',
[Text, Url, Text],
['More weird character in ', "http://facebook.com/#aZ?/:@-._~!$&'()*+,;=", ' that Url'],
['More weird character in ', 'http://facebook.com/#aZ?/:@-._~!$&()*+,;=', ' that Url'],
],
[
'Email with a underscore is n_frasser@example.xyz asd',
Expand All @@ -262,6 +262,11 @@ const tests = [
[Text, Url, Text],
["A link in '", 'singlequote.club/wat', "' extra fluff at the end"],
],
[
"I really like http://singlequote.club's website design",
[Text, Url, Text],
['I really like ', 'http://singlequote.club', "'s website design"],
],
[
'Email with mailsomething dot com domain in foo@mailsomething.com',
[Text, Email],
Expand Down

0 comments on commit a7629c2

Please sign in to comment.