| Index: lib/domain.js |
| =================================================================== |
| --- a/lib/domain.js |
| +++ b/lib/domain.js |
| @@ -41,29 +41,37 @@ |
| /** |
| * Yields all suffixes for a domain. For example, given the domain |
| * <code>www.example.com</code>, this function yields |
| * <code>www.example.com</code>, <code>example.com</code>, and |
| * <code>com</code>, in that order. |
| * |
| * @param {string} domain The domain. |
| + * @param {boolean} [includeBlank] Whether to include the blank suffix at the |
| + * end. |
| + * |
| * @yields {string} The next suffix for the domain. |
| */ |
| -function* suffixes(domain) |
| +function* suffixes(domain, includeBlank = false) |
| { |
| while (domain != "") |
| { |
| yield domain; |
| let dotIndex = domain.indexOf("."); |
| domain = dotIndex == -1 ? "" : domain.substr(dotIndex + 1); |
| } |
| + |
| + if (includeBlank) |
| + yield ""; |
| } |
| +exports.suffixes = suffixes; |
| + |
| /** |
| * Checks whether the given hostname is a domain. |
| * |
| * @param {string} hostname |
| * @returns {boolean} |
| */ |
| function isDomain(hostname) |
| { |