#include "components/url_pattern_index/url_pattern.h"
#include <stddef.h>
#include <ostream>
#include <string_view>
#include "base/check_op.h"
#include "base/notreached.h"
#include "base/numerics/checked_math.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_util.h"
#include "components/url_pattern_index/flat/url_pattern_index_generated.h"
#include "components/url_pattern_index/fuzzy_pattern_matching.h"
#include "components/url_pattern_index/string_splitter.h"
#include "url/gurl.h"
#include "url/third_party/mozilla/url_parse.h"
namespace url_pattern_index {
namespace {
constexpr char kWildcard = …;
class IsWildcard { … };
proto::UrlPatternType ConvertUrlPatternType(flat::UrlPatternType type) { … }
proto::AnchorType ConvertAnchorType(flat::AnchorType type) { … }
std::string_view ConvertString(const flatbuffers::String* string) { … }
bool HasAnyUpperAscii(std::string_view string) { … }
inline bool IsSubdomainAnchored(std::string_view url,
url::Component host,
size_t position) { … }
size_t FindSubpattern(std::string_view text,
std::string_view subpattern,
size_t from = 0) { … }
size_t FindSubdomainAnchoredSubpattern(std::string_view url,
url::Component host,
std::string_view subpattern) { … }
bool DoesTextMatchLastSubpatternInternal(proto::AnchorType anchor_left,
proto::AnchorType anchor_right,
std::string_view text,
url::Component url_host,
std::string_view subpattern) { … }
bool DoesTextMatchLastSubpattern(proto::AnchorType anchor_left,
proto::AnchorType anchor_right,
std::string_view text,
url::Component url_host,
std::string_view subpattern) { … }
bool IsCaseSensitiveMatch(std::string_view url_pattern,
proto::AnchorType anchor_left,
proto::AnchorType anchor_right,
std::string_view url_spec,
url::Component url_host) { … }
}
UrlPattern::UrlInfo::UrlInfo(const GURL& url)
: … { … }
std::string_view UrlPattern::UrlInfo::GetLowerCaseSpec() const { … }
std::string_view UrlPattern::UrlInfo::GetStringHost() const { … }
UrlPattern::UrlInfo::~UrlInfo() = default;
UrlPattern::UrlPattern() = default;
UrlPattern::UrlPattern(std::string_view url_pattern,
proto::UrlPatternType type,
MatchCase match_case)
: … { … }
UrlPattern::UrlPattern(std::string_view url_pattern,
proto::AnchorType anchor_left,
proto::AnchorType anchor_right)
: … { … }
UrlPattern::UrlPattern(const flat::UrlRule& rule)
: … { … }
UrlPattern::~UrlPattern() = default;
bool UrlPattern::MatchesUrl(const UrlInfo& url) const { … }
std::ostream& operator<<(std::ostream& out, const UrlPattern& pattern) { … }
}