MCPcopy Create free account
hub / github.com/davidgiven/luje / isValidDomainName

Method isValidDomainName

lib/java/net/URI.java:613–636  ·  view source on GitHub ↗
(String host)

Source from the content-addressed store, hash-verified

611 }
612
613 private boolean isValidDomainName(String host) {
614 try {
615 URIEncoderDecoder.validateSimple(host, "-."); //$NON-NLS-1$
616 } catch (URISyntaxException e) {
617 return false;
618 }
619
620 String label = null;
621 StringTokenizer st = new StringTokenizer(host, "."); //$NON-NLS-1$
622 while (st.hasMoreTokens()) {
623 label = st.nextToken();
624 if (label.startsWith("-") || label.endsWith("-")) { //$NON-NLS-1$ //$NON-NLS-2$
625 return false;
626 }
627 }
628
629 if (!label.equals(host)) {
630 char ch = label.charAt(0);
631 if (ch >= '0' && ch <= '9') {
632 return false;
633 }
634 }
635 return true;
636 }
637
638 private boolean isValidIPv4Address(String host) {
639 int index;

Callers 1

isValidHostMethod · 0.95

Calls 7

validateSimpleMethod · 0.95
hasMoreTokensMethod · 0.95
nextTokenMethod · 0.95
startsWithMethod · 0.95
endsWithMethod · 0.95
equalsMethod · 0.95
charAtMethod · 0.95

Tested by

no test coverage detected