
ru.tinkoff.plugins.buildmetrics.gradle.internal.utils.UrlUtils.kt Maven / Gradle / Ivy
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 - 2025 Weber Informatics LLC | Privacy Policy