diff --git a/include/ada/url_pattern_helpers-inl.h b/include/ada/url_pattern_helpers-inl.h index 0e97e40fd..370a44a19 100644 --- a/include/ada/url_pattern_helpers-inl.h +++ b/include/ada/url_pattern_helpers-inl.h @@ -320,11 +320,12 @@ inline void Tokenizer::get_next_code_point() { code_point = first_byte; ada_log("Tokenizer::get_next_code_point returning ASCII code point=", uint32_t(code_point)); - ada_log("Tokenizer::get_next_code_point next_index =", next_index, " input.size() =", input.size()); + ada_log("Tokenizer::get_next_code_point next_index =", next_index, + " input.size()=", input.size()); return; } ada_log("Tokenizer::get_next_code_point read first byte=", - uint32_t(first_byte)); + uint32_t(first_byte)); if ((first_byte & 0xE0) == 0xC0) { code_point = first_byte & 0x1F; number_bytes = 2; @@ -338,17 +339,17 @@ inline void Tokenizer::get_next_code_point() { number_bytes = 4; ada_log("Tokenizer::get_next_code_point four bytes"); } - ADA_ASSERT_TRUE(number_bytes + next_index < input.size()); + ADA_ASSERT_TRUE(number_bytes + next_index <= input.size()); for (size_t i = 1 + next_index; i < number_bytes + next_index; ++i) { unsigned char byte = input[i]; - ada_log("Tokenizer::get_next_code_point read byte=", - uint32_t(byte)); + ada_log("Tokenizer::get_next_code_point read byte=", uint32_t(byte)); code_point = (code_point << 6) | (byte & 0x3F); } ada_log("Tokenizer::get_next_code_point returning non-ASCII code point=", uint32_t(code_point)); - ada_log("Tokenizer::get_next_code_point next_index =", next_index, " input.size() =", input.size()); + ada_log("Tokenizer::get_next_code_point next_index =", next_index, + " input.size()=", input.size()); next_index += number_bytes; } diff --git a/src/url_pattern_helpers.cpp b/src/url_pattern_helpers.cpp index 85866e9d8..6b8f1eae8 100644 --- a/src/url_pattern_helpers.cpp +++ b/src/url_pattern_helpers.cpp @@ -9,6 +9,9 @@ namespace ada::url_pattern_helpers { inline std::optional constructor_string_parser::compute_protocol_matches_special_scheme_flag() { + ada_log( + "constructor_string_parser::compute_protocol_matches_special_scheme_" + "flag"); // Let protocol string be the result of running make a component string given // parser. auto protocol_string = make_component_string(); @@ -18,6 +21,8 @@ constructor_string_parser::compute_protocol_matches_special_scheme_flag() { protocol_string, canonicalize_protocol, url_pattern_compile_component_options::DEFAULT); if (!protocol_component) { + ada_log("url_pattern_component::compile failed for protocol_string ", + protocol_string); return protocol_component.error(); } // If the result of running protocol component matches a special scheme given @@ -348,6 +353,7 @@ constructor_string_parser::parse(std::string_view input) { // Run compute protocol matches a special scheme flag given parser. if (const auto error = parser.compute_protocol_matches_special_scheme_flag()) { + ada_log("compute_protocol_matches_special_scheme_flag failed"); return tl::unexpected(*error); } // Let next state be "pathname". diff --git a/tests/wpt_urlpattern_tests.cpp b/tests/wpt_urlpattern_tests.cpp index 16df9bac9..c7c4d7d7b 100644 --- a/tests/wpt_urlpattern_tests.cpp +++ b/tests/wpt_urlpattern_tests.cpp @@ -230,7 +230,7 @@ TEST(wpt_urlpattern_tests, urlpattern_test_data) { if (!main_object["expected_obj"].get_string().get(expected_obj) && expected_obj == "error") { - if (parse_result.has_value()) { + if (parse_result.value().has_value()) { main_object.reset(); FAIL() << "Test should have failed but it didn't" << std::endl << main_object.raw_json().value() << std::endl;