class NetUtils {

  public static String normalize(String path) {
    if (path == null) {
      return NetConstants.ROOT;
    }

    int len = path.length();
    if (len == 0) {
      return NetConstants.ROOT;
    }

    if (path.charAt(0) != NetConstants.PATH_SEPARATOR) {
      throw new IllegalArgumentException(
          "Network Location path does not start with "
              + NetConstants.PATH_SEPARATOR_STR + ": " + path);
    }

    // Remove any trailing NetConstants.PATH_SEPARATOR
    return len == 1 ? path : StringUtils.removeEnd(path,
        NetConstants.PATH_SEPARATOR_STR);
  }

  private  NetUtils();

}