ru.tinkoff.plugins.buildmetrics.gradle.internal.utils.UrlUtils.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of build-metrics-gradle Show documentation
Show all versions of build-metrics-gradle Show documentation
Extension for tinkoff build metrics gradle plugin.
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