diff --git a/packages/message-parser/src/grammar.pegjs b/packages/message-parser/src/grammar.pegjs index a9c1249d68..7f23e650b9 100644 --- a/packages/message-parser/src/grammar.pegjs +++ b/packages/message-parser/src/grammar.pegjs @@ -476,7 +476,7 @@ urlAuthorityHostName urlAuthorityPort = digits // TODO: from "0" to "65535" -urlPath = $("/" $(!"?" !"/" !"#" !")" !">" !"|" .)* urlPath*) +urlPath = $("/" $(!"?" !"/" !"#" !")" !">" !"|" !" " .)* urlPath*) urlQuery = $("?" $(alpha_digit / safe)*) diff --git a/packages/message-parser/tests/url.test.ts b/packages/message-parser/tests/url.test.ts index e233ff3f3c..7fe1be3dd6 100644 --- a/packages/message-parser/tests/url.test.ts +++ b/packages/message-parser/tests/url.test.ts @@ -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); });