- Timestamp:
- 2019-11-05T21:04:09+13:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs3-extensions/maori-lang-detection/src/org/greenstone/atea/Utility.java
r33604 r33623 82 82 } 83 83 84 /** Work out the 'domain' for a given url. 85 * This retains any www. or subdomain prefix. 86 */ 87 public static String getDomainForURL(String url, boolean withProtocol) { 88 int startIndex = startIndex = url.indexOf("//"); // for http:// or https:// prefix 89 startIndex = (startIndex == -1) ? 0 : (startIndex+2); // skip past the protocol's // portion 90 // the keep the URL around in case param withProtocol=true 91 String protocol = (startIndex == -1) ? "" : url.substring(0, startIndex); 92 93 String domain = url.substring(startIndex); 94 int endIndex = domain.indexOf("/"); 95 if(endIndex == -1) endIndex = domain.length(); 96 domain = domain.substring(0, endIndex); 97 98 if(withProtocol) { 99 // now that we have the domain (everything to the first / when there is no protocol) 100 // can glue the protocol back on 101 domain = protocol + domain; 102 } 103 104 return domain; 105 } 106 84 107 public static boolean isDomainInCountry(String domainWithProtocol, 85 108 String countryCode, File geoLiteCityDatFile)
Note:
See TracChangeset
for help on using the changeset viewer.