diff --git a/android/guava/src/com/google/common/net/InternetDomainName.java b/android/guava/src/com/google/common/net/InternetDomainName.java index d71a9d5c3c6c..4f85fb67c124 100644 --- a/android/guava/src/com/google/common/net/InternetDomainName.java +++ b/android/guava/src/com/google/common/net/InternetDomainName.java @@ -167,6 +167,12 @@ private int findSuffixOfType(Optional desiredType) { for (int i = 0; i < partsSize; i++) { String ancestorName = DOT_JOINER.join(parts.subList(i, partsSize)); + if (i > 0 + && matchesType( + desiredType, Optional.fromNullable(PublicSuffixPatterns.UNDER.get(ancestorName)))) { + return i - 1; + } + if (matchesType( desiredType, Optional.fromNullable(PublicSuffixPatterns.EXACT.get(ancestorName)))) { return i; @@ -178,10 +184,6 @@ private int findSuffixOfType(Optional desiredType) { if (PublicSuffixPatterns.EXCLUDED.containsKey(ancestorName)) { return i + 1; } - - if (matchesWildcardSuffixType(desiredType, ancestorName)) { - return i; - } } return NO_SUFFIX_FOUND; @@ -591,18 +593,6 @@ public static boolean isValid(String name) { } } - /** - * Does the domain name match one of the "wildcard" patterns (e.g. {@code "*.ar"})? If a {@code - * desiredType} is specified, the wildcard pattern must also match that type. - */ - private static boolean matchesWildcardSuffixType( - Optional desiredType, String domain) { - List pieces = DOT_SPLITTER.limit(2).splitToList(domain); - return pieces.size() == 2 - && matchesType( - desiredType, Optional.fromNullable(PublicSuffixPatterns.UNDER.get(pieces.get(1)))); - } - /** * If a {@code desiredType} is specified, returns true only if the {@code actualType} is * identical. Otherwise, returns true as long as {@code actualType} is present. diff --git a/guava/src/com/google/common/net/InternetDomainName.java b/guava/src/com/google/common/net/InternetDomainName.java index d71a9d5c3c6c..4f85fb67c124 100644 --- a/guava/src/com/google/common/net/InternetDomainName.java +++ b/guava/src/com/google/common/net/InternetDomainName.java @@ -167,6 +167,12 @@ private int findSuffixOfType(Optional desiredType) { for (int i = 0; i < partsSize; i++) { String ancestorName = DOT_JOINER.join(parts.subList(i, partsSize)); + if (i > 0 + && matchesType( + desiredType, Optional.fromNullable(PublicSuffixPatterns.UNDER.get(ancestorName)))) { + return i - 1; + } + if (matchesType( desiredType, Optional.fromNullable(PublicSuffixPatterns.EXACT.get(ancestorName)))) { return i; @@ -178,10 +184,6 @@ private int findSuffixOfType(Optional desiredType) { if (PublicSuffixPatterns.EXCLUDED.containsKey(ancestorName)) { return i + 1; } - - if (matchesWildcardSuffixType(desiredType, ancestorName)) { - return i; - } } return NO_SUFFIX_FOUND; @@ -591,18 +593,6 @@ public static boolean isValid(String name) { } } - /** - * Does the domain name match one of the "wildcard" patterns (e.g. {@code "*.ar"})? If a {@code - * desiredType} is specified, the wildcard pattern must also match that type. - */ - private static boolean matchesWildcardSuffixType( - Optional desiredType, String domain) { - List pieces = DOT_SPLITTER.limit(2).splitToList(domain); - return pieces.size() == 2 - && matchesType( - desiredType, Optional.fromNullable(PublicSuffixPatterns.UNDER.get(pieces.get(1)))); - } - /** * If a {@code desiredType} is specified, returns true only if the {@code actualType} is * identical. Otherwise, returns true as long as {@code actualType} is present.