/** * Returns the index of the leftmost part of the suffix, or -1 if not found. Note that the value * defined as a suffix may not produce {@code true} results from {@link #isPublicSuffix()} or * {@link #isRegistrySuffix()} if the domain ends with an excluded domain pattern such as {@code * "nhs.uk"}. * * <p>If a {@code desiredType} is specified, this method only finds suffixes of the given type. * Otherwise, it finds the first suffix of any type. */ private int findSuffixOfType(Optional<PublicSuffixType> desiredType) { final int partsSize = parts.size(); for (int i = 0; i < partsSize; i++) { String ancestorName = DOT_JOINER.join(parts.subList(i, partsSize)); if (matchesType( desiredType, Optional.fromNullable(PublicSuffixPatterns.EXACT.get(ancestorName)))) { return i; } // Excluded domains (e.g. !nhs.uk) use the next highest // domain as the effective public suffix (e.g. uk). if (PublicSuffixPatterns.EXCLUDED.containsKey(ancestorName)) { return i + 1; } if (matchesWildcardSuffixType(desiredType, ancestorName)) { return i; } } return NO_SUFFIX_FOUND; }
/** * Returns the index of the leftmost part of the suffix, or -1 if not found. Note that the value * defined as a suffix may not produce {@code true} results from {@link #isPublicSuffix()} or * {@link #isRegistrySuffix()} if the domain ends with an excluded domain pattern such as {@code * "nhs.uk"}. * * <p>If a {@code desiredType} is specified, this method only finds suffixes of the given type. * Otherwise, it finds the first suffix of any type. */ private int findSuffixOfType(Optional<PublicSuffixType> desiredType) { final int partsSize = parts.size(); for (int i = 0; i < partsSize; i++) { String ancestorName = DOT_JOINER.join(parts.subList(i, partsSize)); if (matchesType( desiredType, Optional.fromNullable(PublicSuffixPatterns.EXACT.get(ancestorName)))) { return i; } // Excluded domains (e.g. !nhs.uk) use the next highest // domain as the effective public suffix (e.g. uk). if (PublicSuffixPatterns.EXCLUDED.containsKey(ancestorName)) { return i + 1; } if (matchesWildcardSuffixType(desiredType, ancestorName)) { return i; } } return NO_SUFFIX_FOUND; }
/** * Returns the index of the leftmost part of the suffix, or -1 if not found. Note that the value * defined as a suffix may not produce {@code true} results from {@link #isPublicSuffix()} or * {@link #isRegistrySuffix()} if the domain ends with an excluded domain pattern such as {@code * "nhs.uk"}. * * <p>If a {@code desiredType} is specified, this method only finds suffixes of the given type. * Otherwise, it finds the first suffix of any type. */ private int findSuffixOfType(Optional<PublicSuffixType> desiredType) { final int partsSize = parts.size(); for (int i = 0; i < partsSize; i++) { String ancestorName = DOT_JOINER.join(parts.subList(i, partsSize)); if (matchesType( desiredType, Optional.fromNullable(PublicSuffixPatterns.EXACT.get(ancestorName)))) { return i; } // Excluded domains (e.g. !nhs.uk) use the next highest // domain as the effective public suffix (e.g. uk). if (PublicSuffixPatterns.EXCLUDED.containsKey(ancestorName)) { return i + 1; } if (matchesWildcardSuffixType(desiredType, ancestorName)) { return i; } } return NO_SUFFIX_FOUND; }
/** * Returns the index of the leftmost part of the suffix, or -1 if not found. Note that the value * defined as a suffix may not produce {@code true} results from {@link #isPublicSuffix()} or * {@link #isRegistrySuffix()} if the domain ends with an excluded domain pattern such as {@code * "nhs.uk"}. * * <p>If a {@code desiredType} is specified, this method only finds suffixes of the given type. * Otherwise, it finds the first suffix of any type. */ private int findSuffixOfType(Optional<PublicSuffixType> desiredType) { final int partsSize = parts.size(); for (int i = 0; i < partsSize; i++) { String ancestorName = DOT_JOINER.join(parts.subList(i, partsSize)); if (matchesType( desiredType, Optional.fromNullable(PublicSuffixPatterns.EXACT.get(ancestorName)))) { return i; } // Excluded domains (e.g. !nhs.uk) use the next highest // domain as the effective public suffix (e.g. uk). if (PublicSuffixPatterns.EXCLUDED.containsKey(ancestorName)) { return i + 1; } if (matchesWildcardSuffixType(desiredType, ancestorName)) { return i; } } return NO_SUFFIX_FOUND; }
/** * Returns the index of the leftmost part of the suffix, or -1 if not found. Note that the value * defined as a suffix may not produce {@code true} results from {@link #isPublicSuffix()} or * {@link #isRegistrySuffix()} if the domain ends with an excluded domain pattern such as {@code * "nhs.uk"}. * * <p>If a {@code desiredType} is specified, this method only finds suffixes of the given type. * Otherwise, it finds the first suffix of any type. */ private int findSuffixOfType(Optional<PublicSuffixType> desiredType) { final int partsSize = parts.size(); for (int i = 0; i < partsSize; i++) { String ancestorName = DOT_JOINER.join(parts.subList(i, partsSize)); if (matchesType( desiredType, Optional.fromNullable(PublicSuffixPatterns.EXACT.get(ancestorName)))) { return i; } // Excluded domains (e.g. !nhs.uk) use the next highest // domain as the effective public suffix (e.g. uk). if (PublicSuffixPatterns.EXCLUDED.containsKey(ancestorName)) { return i + 1; } if (matchesWildcardSuffixType(desiredType, ancestorName)) { return i; } } return NO_SUFFIX_FOUND; }