-
Notifications
You must be signed in to change notification settings - Fork 331
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
Add url.includes_credentials() and url.is_special(). #520
base: main
Are you sure you want to change the base?
Conversation
A new method for https://url.spec.whatwg.org/#cannot-have-a-username-password-port could be used in |
I decided to refactor the method contents to explicitly match the specification: |
☔ The latest upstream changes (presumably #537) made this pull request unmergeable. Please resolve the merge conflicts. |
Rebased to master :) |
☔ The latest upstream changes (presumably e003e93) made this pull request unmergeable. Please resolve the merge conflicts. |
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.
Thanks for working on these helper functions! I have some some questions about the details, but the direction looks great.
/// # } | ||
/// # run().unwrap(); | ||
/// ``` | ||
pub fn is_special(&self) -> bool { |
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.
As I understand it, "special" is really about the scheme (which matches the docs), whereas a Url::is_special()
method seems to be about the whole URL. Should this be renamed to is_special_scheme()
or is_scheme_special()
or has_special_scheme()
?
/// # run().unwrap(); | ||
/// ``` | ||
pub fn includes_credentials(&self) -> bool { | ||
self.username() != "" || self.password().unwrap_or(&"") != "" |
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'm confused about this code, is it even possible to have a password without username?
@@ -2361,6 +2358,12 @@ impl Url { | |||
|
|||
// Private helper methods: | |||
|
|||
fn cannot_have_username_password_port(&self) -> bool { | |||
self.host().unwrap_or(Host::Domain("")) == Host::Domain("") |
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.
It would be nice to link https://url.spec.whatwg.org/#url-miscellaneous in a comment here.
As part of #480 this pull request adds includes_credentials and is_special to url, which are defined in the Miscellaneous section.
There are probably other cool helper methods to add, but I don't know which ones would make sense.
This change is