All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ru.tinkoff.plugins.buildmetrics.gradle.internal.utils.UrlUtils.kt Maven / Gradle / Ivy

There is a newer version: 2.0.0-RC2
Show newest version
package ru.tinkoff.plugins.buildmetrics.gradle.internal.utils

/**
 * Extracts the host name from the URL represented by this String.
 *
 * This function assumes that the URL has a proper scheme followed by '://',
 * and that the host name is terminated by the first '/' or by a port number
 * indicated with a ':' (if present) after the scheme.
 *
 * Example:
 * "http://www.example.com:8080/path/to/resource" -> "www.example.com"
 * "https://repo.maven.apache.org/maven2/" -> "repo.maven.apache.org"
 *
 * @return The host name of the URL or source String if the URL does not contain required symbols.
 */
internal fun String.hostNameFromUrl(): String {
    return substringAfter("://").substringBefore("/").substringBefore(":")
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy