Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse URLs after sentence dot correctly #3142

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/api/src/rich-text/util.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const MENTION_REGEX = /(^|\s|\()(@)([a-zA-Z0-9.-]+)(\b)/g
export const URL_REGEX =
/(^|\s|\()((https?:\/\/[\S]+)|((?<domain>[a-z][a-z0-9]*(\.[a-z0-9]+)+)[\S]*))/gim
/(^|\s|\(|\b)((https?:\/\/[\S]+)|((?<domain>[a-z][a-z0-9]*(?!\.https?:\/\/)(\.[a-z0-9]+)+)[\S]*))/gim
export const TRAILING_PUNCTUATION_REGEX = /\p{P}+$/gu

/**
Expand Down
4 changes: 4 additions & 0 deletions packages/api/tests/rich-text-detection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ describe('detectFacets', () => {
'start middle https://end.com/foo/bar?baz=bux#hash',
'https://newline1.com\nhttps://newline2.com',
'👨‍👩‍👧‍👧 https://middle.com 👨‍👩‍👧‍👧',
'Check this out.https://afterdot.com',
'Check this out!https://afterdot.com',

'start middle.com end',
'start middle.com/foo/bar end',
Expand Down Expand Up @@ -122,6 +124,8 @@ describe('detectFacets', () => {
['https://newline2.com', 'https://newline2.com'],
],
[['👨‍👩‍👧‍👧 '], ['https://middle.com', 'https://middle.com'], [' 👨‍👩‍👧‍👧']],
[['Check this out.'], ['https://afterdot.com', 'https://afterdot.com']],
[['Check this out!'], ['https://afterdot.com', 'https://afterdot.com']],

[['start '], ['middle.com', 'https://middle.com'], [' end']],
[
Expand Down