Index: lib/domain.js
===================================================================
--- a/lib/domain.js
+++ b/lib/domain.js
@@ -35,16 +35,29 @@
for (let key in publicSuffixes)
map.set(key, publicSuffixes[key]);
return map;
}
/**
+ * Normalizes a hostname.
+ * @param {string} hostname
+ * @returns {string}
+ */
+function normalizeHostname(hostname)
+{
+ return (hostname[hostname.length - 1] == "." ?
+ hostname.replace(/\.+$/, "") : hostname).toLowerCase();
+}
+
+exports.normalizeHostname = normalizeHostname;
+
+/**
* Yields all suffixes for a domain. For example, given the domain
* www.example.com
, this function yields
* www.example.com
, example.com
, and
* com
, in that order.
*
* @param {string} domain The domain.
* @param {boolean} [includeBlank] Whether to include the blank suffix at the
* end.