diff --git a/packages/message-parser/src/grammar.pegjs b/packages/message-parser/src/grammar.pegjs index 8525d84f16..a9c1249d68 100644 --- a/packages/message-parser/src/grammar.pegjs +++ b/packages/message-parser/src/grammar.pegjs @@ -27,7 +27,7 @@ strike, task, tasks, - unorderedList + unorderedList, } = require('./utils'); } @@ -355,7 +355,6 @@ extra / ":" / ";" / "," - / " " / "(" / ")" / "?" @@ -477,7 +476,7 @@ urlAuthorityHostName urlAuthorityPort = digits // TODO: from "0" to "65535" -urlPath = $("/" $(alpha_digit / safe)* urlPath*) +urlPath = $("/" $(!"?" !"/" !"#" !")" !">" !"|" .)* urlPath*) urlQuery = $("?" $(alpha_digit / safe)*) diff --git a/packages/message-parser/tests/link.test.ts b/packages/message-parser/tests/link.test.ts index bf4fe55be3..572665dd01 100644 --- a/packages/message-parser/tests/link.test.ts +++ b/packages/message-parser/tests/link.test.ts @@ -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')])], diff --git a/packages/message-parser/tests/url.test.ts b/packages/message-parser/tests/url.test.ts index 5f2609d393..e233ff3f3c 100644 --- a/packages/message-parser/tests/url.test.ts +++ b/packages/message-parser/tests/url.test.ts @@ -60,6 +60,22 @@ test.each([ ['ssh://test@test.test', [paragraph([link('ssh://test@test.test')])]], ['custom://test@test.test', [paragraph([link('custom://test@test.test')])]], ['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); });