Skip to content

Conversation

@ipc103
Copy link
Contributor

@ipc103 ipc103 commented Aug 11, 2022

When inserted markdown links, we were testing the pasted text to see if it contained a URL (via a RegExp that was looking for https?) and, if it matched, attempting to use that as the URL for a markdown link with the target text as the text. However, this causes an undesired behavior if there's additional text that's being pasted. See the example videos below:

Screen.Recording.2022-08-10.at.9.02.23.PM.mov

This PR tightens up the RegEx to ensure we're pasting an exact URL. I tweaked the RegEx logic from this SO post https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url

When the text being pasted contained a URL, we were attempting to convert the target text into a markdown link. However, this was causing some undeseried behavior, because the pasted text was being treated like an exact URL. This updates the RegExp test to look for an exact string of a URL so that we don't match on longer strings.

Borrowed from SO: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url
@ipc103 ipc103 requested a review from a team as a code owner August 11, 2022 01:06
@ipc103 ipc103 requested a review from manuelpuyol August 11, 2022 01:06
@manuelpuyol manuelpuyol merged commit 2cf7f94 into github:main Aug 11, 2022
@ipc103 ipc103 deleted the update-paste-links branch August 11, 2022 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants