Creates an url using base url and appending optional segments.

@param baseUrl a {@code non-null} string which will act as a base.
@param pathSegments an option array of segments
@return a string representing an absolute-url
555799
public static String urlFrom( String baseUrl,
                                  String... pathSegments ) {
        StringBuilder urlBuilder = new StringBuilder(baseUrl);
        if (urlBuilder.charAt(urlBuilder.length() - 1) == '/') {
            urlBuilder.deleteCharAt(urlBuilder.length() - 1);
        }
        for (String pathSegment : pathSegments) {
            if (pathSegment.equalsIgnoreCase("..")) {
                urlBuilder.delete(urlBuilder.lastIndexOf("/"), urlBuilder.length());
            } else {
                if (!pathSegment.startsWith("/")) {
                    urlBuilder.append("/");
                }
                urlBuilder.append(pathSegment);
            }
        }
        return urlBuilder.toString();
    }
1310211
public UriComponentsBuilder pathSegment(String... pathSegments) throws IllegalArgumentException {
		Assert.notNull(pathSegments, "'segments' must not be null");
		this.pathBuilder.addPathSegments(pathSegments);
		resetSchemeSpecificPart();
		return this;
	}
249085
public static String buildUrl(String baseUrl, String path) {
        if (path.startsWith("http:") || path.startsWith("https:")) {
            return path;
        }
        if (StringUtils.isEmpty(baseUrl)) {
            return file2url(concatPath(LOCAL_BASE_URL, path));
        } else {
            if (baseUrl.startsWith("http:") || baseUrl.startsWith("https:")) {
                return concatPath(baseUrl, path);
            } else {
                return concatPath(file2url(baseUrl), path);
            }
        }
    }
671443
public ArmeriaRetrofitBuilder baseUrl(String baseUrl) {
        requireNonNull(baseUrl, "baseUrl");
        final URI uri = URI.create(baseUrl);
        checkArgument(SessionProtocol.find(uri.getScheme()).isPresent(),
                      "baseUrl must have an HTTP scheme: %s", baseUrl);
        final String path = uri.getPath();
        if (!path.isEmpty() && !SLASH.equals(path.substring(path.length() - 1))) {
            throw new IllegalArgumentException("baseUrl must end with /: " + baseUrl);
        }
        this.baseUrl = baseUrl;
        return this;
    }
74156
public static String createPath(String... segments) {

    int length = 0;
    for (String s : segments) {
      if (length > 0) {
        length++;
      }
      length = length + s.length();
    }
    StringBuilder buffer = new StringBuilder(length);
    appendPath(buffer, segments);
    return buffer.toString();
  }
605561
@Override
    public void setBaseUrl(String baseUrl){
        this.endpointUrl = Utils.trimEnd(baseUrl, '/');
        super.setBaseUrl(baseUrl);
    }
538621
function buildPath (basePath, queryParams) {
    basePath = basePath.concat('?')
    var url = basePath.concat(queryString.stringify(queryParams))
    return url
  }
69120
public static function createFromSegments(iterable $segments, int $type = self::IS_RELATIVE): self
    {
        static $type_list = [self::IS_ABSOLUTE => 1, self::IS_RELATIVE => 1];

        if (!isset($type_list[$type])) {
            throw new PathTypeNotFound(sprintf('"%s" is an invalid or unsupported %s type', $type, self::class));
        }

        $pathSegments = [];
        foreach ($segments as $value) {
            if (!is_scalar($value) && !method_exists($value, '__toString')) {
                throw new TypeError('The submitted segments are invalid');
            }
            $pathSegments[] = (string) $value;
        }

        $path = implode(self::SEPARATOR, $pathSegments);
        if (static::IS_ABSOLUTE !== $type) {
            return new self(ltrim($path, self::SEPARATOR));
        }

        if (self::SEPARATOR !== ($path[0] ?? '')) {
            return new self(self::SEPARATOR.$path);
        }

        return new self($path);
    }
215879
public static URL generateUrl(final String url) throws OMDBException {
        try {
            return new URL(url);
        } catch (MalformedURLException ex) {
            throw new OMDBException(ApiExceptionType.INVALID_URL, "Failed to create URL", url, ex);
        }
    }
732556
protected function makeAbsoluteUrl($relativeUrl, $baseUrl = null)
    {
        $baseUrl = $baseUrl ?: $this->baseUrl;
        if (empty($baseUrl)) {
            throw new \RuntimeException('No base URL');
        }
        $base = \GuzzleHttp\Psr7\uri_for($baseUrl);

        return $base->withPath($relativeUrl)->__toString();
    }
1266461
public static String getLastSegment(final List<PathSegment> segments) {
        if (segments.isEmpty()) {
            return "";
        }
        return segments.get(segments.size() - 1).getPath();
    }
236322
public URI baseURL() {
        StringBuilder b = new StringBuilder()
                .append(protocol())
                .append(host())
                .append(":")
                .append(port())
                .append("/")
                .append(versionPrefix())
                .append("/");
        try {
            return new URI(b.toString());
        } catch (URISyntaxException e) {
            throw new IllegalArgumentException("Unable to construct a base URL for the API", e);
        }
    }
1215956
function(url) {

        // Note: this is rudamentary.. not sure yet if it handles every case.
        if (/^https?:\/\//i.test(url)) {
            // absolute
            return url;
        }

        var baseParts = this.parseUrl(this.baseUrl);
        if (url.charAt('/')) {
            // Url starts with a slash
            return baseParts.root + url;
        }

        // Url does not start with a slash, we need grab the base url right up until the last slash.
        var newUrl = baseParts.root + '/';
        if (baseParts.path.lastIndexOf('/')!==-1) {
            newUrl = newUrl = baseParts.path.subString(0, baseParts.path.lastIndexOf('/')) + '/';
        }
        newUrl+=url;
        return url;

    }
1338796
public PathAddress append(List<PathElement> additionalElements) {
        final ArrayList<PathElement> newList = new ArrayList<PathElement>(pathAddressList.size() + additionalElements.size());
        newList.addAll(pathAddressList);
        newList.addAll(additionalElements);
        return pathAddress(newList);
    }
288408
@Override
    public ElevationProvider setBaseURL(String baseURL) {
        String[] urls = baseURL.split(";");
        if (urls.length != 2) {
            throw new IllegalArgumentException("The base url must consist of two urls separated by a ';'. The first for cgiar, the second for gmted");
        }
        srtmProvider.setBaseURL(urls[0]);
        globalProvider.setBaseURL(urls[1]);
        return this;
    }
1116009
def append_url(base_url, path):
    
    if base_url[-1] != "/":
        base_url += "/"
    if path[0] == "/":
        path = path[1:]
    return urljoin(base_url, path)
322213
private String appendBasePath(String path) {
		try {
			return new URL(baseUrl, path).toString();
		} catch (MalformedURLException e) {
			throw new IllegalArgumentException(format("Cannot combine URLs '%s' and '%s' to valid URL.", baseUrl, path), e);
		}
	}