diff options
Diffstat (limited to 'net/base')
-rw-r--r-- | net/base/dns_util.cc | 8 | ||||
-rw-r--r-- | net/base/dns_util.h | 3 |
2 files changed, 11 insertions, 0 deletions
diff --git a/net/base/dns_util.cc b/net/base/dns_util.cc index db5f606..87d1866 100644 --- a/net/base/dns_util.cc +++ b/net/base/dns_util.cc @@ -70,4 +70,12 @@ bool IsSTD3ASCIIValidCharacter(char c) { return true; } +std::string TrimEndingDot(const std::string& host) { + std::string host_trimmed = host; + size_t len = host_trimmed.length(); + if (len > 1 && host_trimmed[len - 1] == '.') + host_trimmed.erase(len - 1); + return host_trimmed; +} + } // namespace net diff --git a/net/base/dns_util.h b/net/base/dns_util.h index 8eb98f2..f0d2051 100644 --- a/net/base/dns_util.h +++ b/net/base/dns_util.h @@ -20,6 +20,9 @@ bool DNSDomainFromDot(const std::string& dotted, std::string* out); // characters as given in RFC 3490, 4.1, 3(a) bool IsSTD3ASCIIValidCharacter(char c); +// Returns the hostname by trimming the ending dot, if one exists. +std::string TrimEndingDot(const std::string& host); + } // namespace net #endif // NET_BASE_DNS_UTIL_H_ |