code: private String sanitizeUri(String uri) {
          if (uri == null || uri.length() == 0) {
              return null;
          }
          try {
              return new URI(uri).toString();
          } catch (URISyntaxException e) {
              return null;
          }
      }
docs: Returns the sanitized input if it is a URI, or {@code null} otherwise.