Skip to content

Commit

Permalink
chore(model): Guarantee the static value of PurlType to be lowercase
Browse files Browse the repository at this point in the history
This way the explicit conversion can be avoided.

Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Nov 22, 2024
1 parent 883ddb8 commit 4eb24de
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion model/src/main/kotlin/utils/PurlUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ enum class PurlType(private val value: String) {
RPM("rpm"),
SWIFT("swift");

init {
check(value == value.lowercase()) { "The type must be in canonical lowercase form." }
}

companion object {
@JvmStatic
fun fromString(value: String): PurlType =
Expand Down Expand Up @@ -105,7 +109,7 @@ internal fun createPurl(
): String =
buildString {
append("pkg:")
append(type.toString().lowercase())
append(type.toString())
append('/')

if (namespace.isNotEmpty()) {
Expand Down

0 comments on commit 4eb24de

Please sign in to comment.