Skip to content

Commit

Permalink
chore(message-parser): added more tests for url and link cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ggazzo committed Sep 8, 2022
1 parent 62a1582 commit 2957704
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/message-parser/src/grammar.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ urlAuthorityHostName
urlAuthorityPort
= digits // TODO: from "0" to "65535"

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

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

Expand Down
39 changes: 39 additions & 0 deletions packages/message-parser/tests/url.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,45 @@ test.each([
]),
],
],
[
'https://developer.rocket.chat/reference/api/rest-api look at this',
[
paragraph([
link('https://developer.rocket.chat/reference/api/rest-api'),
plain(' look at this'),
]),
],
],

[
'https://developer.rocket.chat/reference/api/rest-api#fragment?query=query look at this',
[
paragraph([
link(
'https://developer.rocket.chat/reference/api/rest-api#fragment?query=query'
),
plain(' look at this'),
]),
],
],
[
'https://developer.rocket.chat look at this',
[
paragraph([
link('https://developer.rocket.chat'),
plain(' look at this'),
]),
],
],
[
'https://developer.rocket.chat?query=query look at this',
[
paragraph([
link('https://developer.rocket.chat?query=query'),
plain(' look at this'),
]),
],
],
])('parses %p', (input, output) => {
expect(parse(input)).toMatchObject(output);
});
Expand Down

0 comments on commit 2957704

Please sign in to comment.