view env/lib/python3.7/site-packages/schema_salad/java/main_utils/DefaultFetcher.java @ 0:26e78fe6e8c4 draft

"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
author shellac
date Sat, 02 May 2020 07:14:21 -0400
parents
children
line wrap: on
line source

package ${package}.utils;

import java.net.URI;

public class DefaultFetcher implements Fetcher {

  public String urlJoin(final String baseUrl, final String url) {
    if (url.startsWith("_:")) {
      return url;
    }

    final URI baseUri = Uris.toUri(baseUrl);
    final URI uri = Uris.toUri(url);
    if (baseUri.getScheme() != null
        && !baseUri.getScheme().equals("file")
        && "file".equals(uri.getScheme())) {
      throw new ValidationException(
          String.format(
              "Not resolving potential remote exploit %s from base %s".format(url, baseUrl)));
    }
    String result = baseUri.resolve(uri).toString();
    if (result.startsWith("file:")) {
      // Well this is gross - needed for http as well?
      result = "file://" + result.substring("file:".length());
    }
    return result;
  }

  public String fetchText(final String url) {
    return "fetched";
  }
}