(Context context, String host)
| 121 | } |
| 122 | |
| 123 | static String getRootDomain(Context context, String host) { |
| 124 | if (host == null) |
| 125 | return null; |
| 126 | String tld = getTld(context, host); |
| 127 | if (tld == null) |
| 128 | return null; |
| 129 | if (tld.equalsIgnoreCase(host)) |
| 130 | return null; |
| 131 | int len = host.length() - tld.length() - 1; |
| 132 | if (len < 0) { |
| 133 | Log.e("getRootDomain host=" + host + " tld=" + tld); |
| 134 | return null; |
| 135 | } |
| 136 | int dot = host.substring(0, len).lastIndexOf('.'); |
| 137 | if (dot < 0) |
| 138 | return host; |
| 139 | return host.substring(dot + 1); |
| 140 | } |
| 141 | |
| 142 | static boolean isTld(Context context, String host) { |
| 143 | if (host == null) |
no test coverage detected