Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/url_pattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,15 +723,21 @@ std::string generate_segment_wildcard_regexp(

bool protocol_component_matches_special_scheme(
ada::url_pattern_component& component) {
// TODO: Optimize this.
auto regex = component.get_regexp();
std::regex rx(regex.data(), regex.size());
std::cmatch cmatch;
return std::regex_match("http", cmatch, rx) ||
try {
std::regex rx(regex.data(), regex.size());
std::cmatch cmatch;
return std::regex_match("http", cmatch, rx) ||
std::regex_match("https", cmatch, rx) ||
std::regex_match("ws", cmatch, rx) ||
std::regex_match("wss", cmatch, rx) ||
std::regex_match("ftp", cmatch, rx);
} catch (...) {
// You probably want to log this error.
ada_log("Error while matching protocol component with special scheme");
ada_log("Regex Input: ", input);
return false;
}
}

} // namespace url_pattern_helpers
Expand Down
Loading