-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Paste: only link selection if URL protocol is http(s) #53000
Conversation
Size Change: +27 B (0%) Total Size: 1.65 MB
ℹ️ View Unchanged
|
Imo no, it's better to let the user add these explicitly since these are much rarer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change looks good to me and fixes the issue.
4d3d9cc
to
1191fd8
Compare
Flaky tests detected in 1191fd8. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6466079195
|
What?
Fixes #24895.
isURL
returns true for any sort of protocol, which results in false positives such asmovie: something
, wheremovie
would be assumed as the protocol. To leave the flexibility ofisURL
and avoid changing this API, we can just add an additional check if the protocol is http(s) for just the link pasting feature. In this case, it's only really meant for these two protocols.If there's more demand, we could add an argument to
isURL
in the future to check for whitelisted protocols.OR we could return the URL instance so you can check as follows:
OR we just use
new URL( text )
directly. What do you think?Anyway, this needs to be fixed, we can thing about the best approach later.
Why?
Pasting anything with a colon over a selection results in a link.
How?
Described above.
Testing Instructions
Copy anything with a colon and paste over a selection. An e2e test has been added.
Testing Instructions for Keyboard
Screenshots or screencast