Skip to content

Commit

Permalink
fix(message-parser): Link is not showing correct and it not opening c…
Browse files Browse the repository at this point in the history
…orrectly (#717)
  • Loading branch information
hugocostadev authored May 11, 2022
1 parent 6fe9fa8 commit 886d2c0
Show file tree
Hide file tree
Showing 2 changed files with 156 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/message-parser/src/grammar.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,10 @@ safe
/ "&"
/ "="
/ "%"
/ "!"
/ "~"
/ "_"
/ "+"

extra
= "!"
Expand Down Expand Up @@ -509,7 +513,16 @@ phonePrefix
*
*/

URL = $(s:urlScheme a:urlAuthority p:urlPath? q:urlQuery? f:urlFragment?)
URL
= $(
s:urlScheme
a:urlAuthority
p:urlPath?
q:urlQuery?
f:urlFragment?
g:urlPath?
h:urlQuery?
)

urlScheme
= $(
Expand Down
142 changes: 142 additions & 0 deletions packages/message-parser/tests/link.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,148 @@ test.each([
]),
],
],
[
'https://desk.rocket.chat/support/rocketchat/ShowHomePage.do#Cases/dv/413244000073043351',
[
paragraph([
link(
'https://desk.rocket.chat/support/rocketchat/ShowHomePage.do#Cases/dv/413244000073043351'
),
]),
],
],
[
'<https://desk.rocket.chat/support/rocketchat/ShowHomePage.do#Cases/dv/413244000073043351|Test>',
[
paragraph([
link(
'https://desk.rocket.chat/support/rocketchat/ShowHomePage.do#Cases/dv/413244000073043351',
plain('Test')
),
]),
],
],
[
'[title](https://desk.rocket.chat/support/rocketchat/ShowHomePage.do#Cases/dv/413244000073043351)',
[
paragraph([
link(
'https://desk.rocket.chat/support/rocketchat/ShowHomePage.do#Cases/dv/413244000073043351',
plain('title')
),
]),
],
],
[
'[**title**](https://desk.rocket.chat/support/rocketchat/ShowHomePage.do#Cases/dv/413244000073043351)',
[
paragraph([
link(
'https://desk.rocket.chat/support/rocketchat/ShowHomePage.do#Cases/dv/413244000073043351',
bold([plain('title')])
),
]),
],
],
[
'[~~title~~](https://desk.rocket.chat/support/rocketchat/ShowHomePage.do#Cases/dv/413244000073043351)',
[
paragraph([
link(
'https://desk.rocket.chat/support/rocketchat/ShowHomePage.do#Cases/dv/413244000073043351',
strike([plain('title')])
),
]),
],
],
[
'[__title__](https://desk.rocket.chat/support/rocketchat/ShowHomePage.do#Cases/dv/413244000073043351)',
[
paragraph([
link(
'https://desk.rocket.chat/support/rocketchat/ShowHomePage.do#Cases/dv/413244000073043351',
italic([plain('title')])
),
]),
],
],
[
'[__**~~title~~**__](https://desk.rocket.chat/support/rocketchat/ShowHomePage.do#Cases/dv/413244000073043351)',
[
paragraph([
link(
'https://desk.rocket.chat/support/rocketchat/ShowHomePage.do#Cases/dv/413244000073043351',
italic([bold([strike([plain('title')])])])
),
]),
],
],
[
'[title](https://desk.rocket.chat/support/rocketchat/ShowHomePage.do#Cases/dv/413244000073043351?query=test12-34)',
[
paragraph([
link(
'https://desk.rocket.chat/support/rocketchat/ShowHomePage.do#Cases/dv/413244000073043351?query=test12-34',
plain('title')
),
]),
],
],
[
'[title](https://desk.rocket.chat/support/rocketchat/ShowHomePage.do?query=test12-34#Cases/dv/413244000073043351)',
[
paragraph([
link(
'https://desk.rocket.chat/support/rocketchat/ShowHomePage.do?query=test12-34#Cases/dv/413244000073043351',
plain('title')
),
]),
],
],
[
'[title](https://desk.rocket.chat/support/rocketchat/ShowHomePage.do#Cases/dv/413244000073043351?query=test12-34&query2=abc123)',
[
paragraph([
link(
'https://desk.rocket.chat/support/rocketchat/ShowHomePage.do#Cases/dv/413244000073043351?query=test12-34&query2=abc123',
plain('title')
),
]),
],
],
[
'[title](https://desk.rocket.chat/support/rocketchat/ShowHomePage.do#Cases?query=test12-34&query2=abcd!e/dv/413244000073043351)',
[
paragraph([
link(
'https://desk.rocket.chat/support/rocketchat/ShowHomePage.do#Cases?query=test12-34&query2=abcd!e/dv/413244000073043351',
plain('title')
),
]),
],
],
[
'[title](https://desk.rocket.chat/support/rocketchat/ShowHomePage.do#Cases?query=test12-34&query2=abcd!e/dv/413244000073043351)',
[
paragraph([
link(
'https://desk.rocket.chat/support/rocketchat/ShowHomePage.do#Cases?query=test12-34&query2=abcd!e/dv/413244000073043351',
plain('title')
),
]),
],
],
[
'[title](https://desk.rocket.chat/support/rocketchat/ShowHomePage.do#Cases/dv/413244000073043351?query=test12-34&query2=abcd!~-._%2B+)',
[
paragraph([
link(
'https://desk.rocket.chat/support/rocketchat/ShowHomePage.do#Cases/dv/413244000073043351?query=test12-34&query2=abcd!~-._%2B+',
plain('title')
),
]),
],
],
])('parses %p', (input, output) => {
expect(parser(input)).toMatchObject(output);
});

0 comments on commit 886d2c0

Please sign in to comment.