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

Fix setters to return correct boolean value #727

Merged
merged 3 commits into from
Sep 2, 2024

Conversation

CarlosEduR
Copy link
Member

@CarlosEduR CarlosEduR commented Sep 2, 2024

Fix: #719

@CarlosEduR
Copy link
Member Author

I noticed we have some other cases here just returning true as well, would it be correct to update all of them to return false instead?

url::parse_scheme

auto parsed_type = ada::scheme::get_scheme_type(input);
bool is_input_special = (parsed_type != ada::scheme::NOT_SPECIAL);
/**
 * In the common case, we will immediately recognize a special scheme (e.g.,
 *http, https), in which case, we can go really fast.
 **/
if (is_input_special) {  // fast path!!!
  if (has_state_override) {
    // If url's scheme is not a special scheme and buffer is a special scheme,
    // then return.
    if (is_special() != is_input_special) {
      return true;
    }
    // If url includes credentials or has a non-null port, and buffer is
    // "file", then return.
    if ((has_credentials() || port.has_value()) &&
        parsed_type == ada::scheme::type::FILE) {
      return true;
    }
    // If url's scheme is "file" and its host is an empty host, then return.
    // An empty host is the empty string.
    if (type == ada::scheme::type::FILE && host.has_value() &&
        host.value().empty()) {
      return true;
    }
  }

  type = parsed_type;

@lemire
Copy link
Member

lemire commented Sep 2, 2024

@CarlosEduR Important work!!!

Yes, I think that in the code sample you have found, it should return false in all the error cases.

@anonrig
Copy link
Member

anonrig commented Sep 2, 2024

@CarlosEduR is this ready to review? i see it as draft?

@CarlosEduR CarlosEduR marked this pull request as ready for review September 2, 2024 22:22
@CarlosEduR
Copy link
Member Author

@anonrig now it is...

Copy link
Member

@lemire lemire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it improves ada.

@anonrig
Copy link
Member

anonrig commented Sep 2, 2024

@CarlosEduR tests seem to be failing with the most recent changes

@lemire
Copy link
Member

lemire commented Sep 2, 2024

@anonrig

tests seem to be failing with the most recent changes

Which tests?

@anonrig
Copy link
Member

anonrig commented Sep 2, 2024

Github UI seems to be failing for me

image

@lemire
Copy link
Member

lemire commented Sep 2, 2024

I am merging.

@lemire lemire merged commit 08851a3 into ada-url:main Sep 2, 2024
37 of 68 checks passed
@CarlosEduR
Copy link
Member Author

desktop web looks ok
image

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.

Set protocol (and perhaps others) errors are silently ignored
3 participants