diff --git a/include/ada/url_pattern.h b/include/ada/url_pattern.h index 13466dd62..aa891d7f3 100644 --- a/include/ada/url_pattern.h +++ b/include/ada/url_pattern.h @@ -198,11 +198,11 @@ class url_pattern_component { // This function explicitly takes a std::string because it is moved. // To avoid unnecessary copy, move each value while calling the constructor. - url_pattern_component(std::string_view new_pattern, std::regex&& new_regexp, + url_pattern_component(std::string&& new_pattern, std::regex&& new_regexp, std::regex_constants::syntax_option_type new_flags, std::vector&& new_group_name_list, bool new_has_regexp_groups) - : regexp(new_regexp), + : regexp(std::move(new_regexp)), pattern(std::move(new_pattern)), flags(new_flags), group_name_list(new_group_name_list), diff --git a/pbcopy b/pbcopy new file mode 100644 index 000000000..55cbc2cb3 --- /dev/null +++ b/pbcopy @@ -0,0 +1,36 @@ +diff --git a/include/ada/url_pattern-inl.h b/include/ada/url_pattern-inl.h +index c7c04a06..6da583e9 100644 +--- a/include/ada/url_pattern-inl.h ++++ b/include/ada/url_pattern-inl.h +@@ -41,7 +41,7 @@ url_pattern_component::create_component_match_result( + // Let value be Get(execResult, ToString(index)). + // Set groups[name] to value. + result.groups.insert({ +- group_name_list[index - 1], ++ "", + exec_result[index].str(), + }); + } +diff --git a/include/ada/url_pattern.h b/include/ada/url_pattern.h +index 13466dd6..7aa41a57 100644 +--- a/include/ada/url_pattern.h ++++ b/include/ada/url_pattern.h +@@ -203,9 +203,8 @@ class url_pattern_component { + std::vector&& new_group_name_list, + bool new_has_regexp_groups) + : regexp(new_regexp), +- pattern(std::move(new_pattern)), ++ pattern(new_pattern), + flags(new_flags), +- group_name_list(new_group_name_list), + has_regexp_groups(new_has_regexp_groups) {} + + // @see https://urlpattern.spec.whatwg.org/#compile-a-component +@@ -223,7 +222,6 @@ class url_pattern_component { + std::regex regexp{}; + std::string pattern{}; + std::regex_constants::syntax_option_type flags = std::regex::ECMAScript; +- std::vector group_name_list{}; + bool has_regexp_groups = false; + }; + diff --git a/src/url_pattern.cpp b/src/url_pattern.cpp index 7f1e80187..0916ce0c5 100644 --- a/src/url_pattern.cpp +++ b/src/url_pattern.cpp @@ -536,7 +536,7 @@ url_pattern_component::compile(std::string_view input, F encoding_callback, // Return a new component whose pattern string is pattern string, regular // expression is regular expression, group name list is name list, and has // regexp groups is has regexp groups. - return url_pattern_component(pattern_string, std::move(regular_expression), + return url_pattern_component(std::move(pattern_string), std::move(regular_expression), flags, std::move(name_list), has_regexp_groups); }