-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Use https by default in prependHTTP util #47467
Conversation
Size Change: +3 B (0%) Total Size: 1.31 MB
ℹ️ View Unchanged
|
Just to say I prefer the other approach where we allow the consumer to modify the protocol as required leaving the existing API in tact. |
@@ -24,7 +24,7 @@ export function prependHTTP( url ) { | |||
|
|||
url = url.trim(); | |||
if ( ! USABLE_HREF_REGEXP.test( url ) && ! isEmail( url ) ) { | |||
return 'http://' + url; | |||
return 'https://' + url; |
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.
This is a potentially breaking change that needs to be documented as one in the package's CHANGELOG.
@@ -24,7 +24,7 @@ export function prependHTTP( url ) { | |||
|
|||
url = url.trim(); | |||
if ( ! USABLE_HREF_REGEXP.test( url ) && ! isEmail( url ) ) { | |||
return 'http://' + url; | |||
return 'https://' + url; |
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.
Actually, I'd generally be against that change, because I'd expect a function called prependHTTP
to prepend http
, not https
. I'd suggest one of these alternative approaches instead:
- Create a new universal function
prependProtocol
that will look at the current protocol (window.location.protocol
if in a browser environment), and consider it when deciding whether to applyhttp
orhttps
. That way we'll keep usinghttp
for local installations that are not on HTTPS, but we'll still properly supporthttps
when applicable. - Create a function
prependHTTPS
that always prependshttps
and in another PR, use that function instead ofprependHTTP
to make it transparent as to what we're doing. That will also help us test the impact of that change in all areas whereprependHTTP
is being used.
In any case, we might want to deprecate prependHTTP
as it will no longer be used and preferred, since sites are recommended to be on https
.
What do you think?
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.
Yeh so I went with adding an option to the existing function in #47312.
But we could just as easily create a new function and deprecate this one.
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.
I agree with you and I think that adding an extra param is of the smallest impact here, since it's not a breaking change. That's why I'm happy to add it here. The downside is the potential confusion that the prependHTTP
function can prepend https
but I guess if we document it well, it can be fine.
@@ -24,7 +24,7 @@ export function prependHTTP( url ) { | |||
|
|||
url = url.trim(); | |||
if ( ! USABLE_HREF_REGEXP.test( url ) && ! isEmail( url ) ) { | |||
return 'http://' + url; | |||
return 'https://' + url; |
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.
We will also need to update some snapshots that previously used http
and will now be using https
.
I think the breaking change of defaulting to |
Closing in favour of suggestion to add HTTPS util. |
What?
Alternative to #47312.
Why?
Because @draganescu suggested it in #47312 (review) so I'm raising it for consideration.
How?
Update the util to always use
https
instead ofhttp
.Testing Instructions
Same as #47312.
Testing Instructions for Keyboard
Screenshots or screencast