MCPcopy Create free account
hub / github.com/apache/nutch / toASCII

Method toASCII

src/java/org/apache/nutch/util/URLUtil.java:413–429  ·  view source on GitHub ↗
(String url)

Source from the content-addressed store, hash-verified

411 }
412
413 public static String toASCII(String url) {
414 try {
415 URL u = new URL(url);
416 String host = u.getHost();
417 if (host == null || host.isEmpty()) {
418 // no host name => no punycoded domain name
419 // also do not add additional slashes for file: URLs (NUTCH-1880)
420 return url;
421 }
422 URI p = new URI(u.getProtocol(), u.getUserInfo(), IDN.toASCII(host),
423 u.getPort(), u.getPath(), u.getQuery(), u.getRef());
424
425 return p.toString();
426 } catch (Exception e) {
427 return null;
428 }
429 }
430
431 public static String toUNICODE(String url) {
432 try {

Callers 4

testToASCIIMethod · 0.95
testFileProtocolMethod · 0.95
runMethod · 0.95
runMethod · 0.95

Calls 5

getProtocolMethod · 0.80
getPortMethod · 0.80
getHostMethod · 0.45
isEmptyMethod · 0.45
toStringMethod · 0.45

Tested by 2

testToASCIIMethod · 0.76
testFileProtocolMethod · 0.76