io.specmatic.core.pattern.URLScheme.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of specmatic-core Show documentation
Show all versions of specmatic-core Show documentation
Turn your contracts into executable specifications. Contract Driven Development - Collaboratively Design & Independently Deploy MicroServices & MicroFrontends.
package io.specmatic.core.pattern
import io.specmatic.core.value.StringValue
enum class URLScheme(val schemes: List) {
HTTP(listOf("http")) {
override val prefix = "${schemes.first()}://"
override val type: String = "an http url"
},
HTTPS(listOf("https")) {
override val prefix = "${schemes.first()}://"
override val type: String = "an https url"
},
PATH(emptyList()) {
override val prefix = ""
override val type: String = "a url path"
override fun matches(url: StringValue): Boolean = true
override val tld: String = ""
},
EITHER(listOf("http", "https")) {
override val prefix = "${schemes.first()}://"
override val type: String = "either an http or or an https url"
};
abstract val prefix: String
abstract val type: String
open val tld: String = ".com"
open fun matches(url: StringValue): Boolean = schemes.any { url.string.startsWith(it) }
}