Skip to content

Commit

Permalink
fix(message-parser): Link parser
Browse files Browse the repository at this point in the history
  • Loading branch information
hugocostadev committed May 10, 2022
1 parent 6fe9fa8 commit 51ffac0
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/message-parser/src/grammar.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,10 @@ 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?
)

urlScheme
= $(
Expand Down
76 changes: 76 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,82 @@ 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')])])])
),
]),
],
],
])('parses %p', (input, output) => {
expect(parser(input)).toMatchObject(output);
});

0 comments on commit 51ffac0

Please sign in to comment.