Skip to content

Commit

Permalink
fix(message-parser): Link broken (#807)
Browse files Browse the repository at this point in the history
Co-authored-by: Diego Sampaio <[email protected]>
  • Loading branch information
ggazzo and sampaiodiego authored Sep 8, 2022
1 parent b480c53 commit 62a1582
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/message-parser/src/grammar.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
strike,
task,
tasks,
unorderedList
unorderedList,
} = require('./utils');
}

Expand Down Expand Up @@ -355,7 +355,6 @@ extra
/ ":"
/ ";"
/ ","
/ " "
/ "("
/ ")"
/ "?"
Expand Down Expand Up @@ -477,7 +476,7 @@ urlAuthorityHostName
urlAuthorityPort
= digits // TODO: from "0" to "65535"

urlPath = $("/" $(alpha_digit / safe)* urlPath*)
urlPath = $("/" $(!"?" !"/" !"#" !")" !">" !"|" .)* urlPath*)

urlQuery = $("?" $(alpha_digit / safe)*)

Expand Down
8 changes: 8 additions & 0 deletions packages/message-parser/tests/link.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,14 @@ test.each([
'[custom](custom://google.com)',
[paragraph([link('custom://google.com', plain('custom'))])],
],
[
'[thing](https://www.thingiverse.com/thing:5451684)',
[
paragraph([
link('https://www.thingiverse.com/thing:5451684', plain('thing')),
]),
],
],
[
'https://t.me/joinchat/chatexample',
[paragraph([link('https://t.me/joinchat/chatexample')])],
Expand Down
16 changes: 16 additions & 0 deletions packages/message-parser/tests/url.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,22 @@ test.each([
['ssh://[email protected]', [paragraph([link('ssh://[email protected]')])]],
['custom://[email protected]', [paragraph([link('custom://[email protected]')])]],
['ftp://test.com', [paragraph([link('ftp://test.com')])]],
[
'https://www.thingiverse.com/thing:5451684',
[paragraph([link('https://www.thingiverse.com/thing:5451684')])],
],
['http://📙.la/❤️', [paragraph([link('http://📙.la/❤️')])]],
[
'https://developer.rocket.chat/reference/api/rest-api#production-security-concerns look at this',
[
paragraph([
link(
'https://developer.rocket.chat/reference/api/rest-api#production-security-concerns'
),
plain(' look at this'),
]),
],
],
])('parses %p', (input, output) => {
expect(parse(input)).toMatchObject(output);
});
Expand Down

0 comments on commit 62a1582

Please sign in to comment.