// Standalone Qt-based Public Suffix List helper.
//
// This code intentionally does not depend on Qt private headers. The generated
// data files are created from public_suffix_list.dat by generate_public_suffix_data.py.

#ifndef RSSGUARD_TOOLS_PUBLICSUFFIX_PUBLICSUFFIX_H
#define RSSGUARD_TOOLS_PUBLICSUFFIX_PUBLICSUFFIX_H

#include <QString>

namespace PublicSuffix {

// Returns true when "domain" is an effective TLD / public suffix according
// to the generated Public Suffix List data.
bool isEffectiveTld(const QString& domain);

// Returns the public suffix of "domain" with a leading dot, matching the old
// QUrl::topLevelDomain() convention. Examples:
//   "www.qt.io"        -> ".io"
//   "feeds.bbc.co.uk" -> ".co.uk"
//   "foo.blogspot.com" with PSL rule "blogspot.com" -> ".blogspot.com"
QString topLevelDomain(const QString& domain);

// Convenience helper returning the registrable domain (eTLD+1).
// Examples:
//   "feeds.bbc.co.uk" -> "bbc.co.uk"
//   "www.qt.io"       -> "qt.io"
QString registrableDomain(const QString& domain);

// Version metadata copied from public_suffix_list.dat by the generator.
QString listVersion();
QString listCommit();

} // namespace PublicSuffix

#endif // RSSGUARD_TOOLS_PUBLICSUFFIX_PUBLICSUFFIX_H
