Skip to content

Commit

Permalink
fix empty prefix case
Browse files Browse the repository at this point in the history
  • Loading branch information
avan1235 committed Mar 26, 2024
1 parent 44d6aa7 commit 664f482
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private data class ShortenedIdentifier(

private fun Shorten.createShortenedIdentifier(): ShortenedIdentifier? {
val url = url.normalizeUrlCase() ?: return null
val prefix = customPrefix?.encodeURLPath(encodeSlash = true, encodeEncoded = false)
val prefix = customPrefix?.takeIf { it.isNotEmpty() }?.encodeURLPath(encodeSlash = true, encodeEncoded = false)
val id = url.sha256().let { uniqueId ->
prefix?.let { "$it-$uniqueId" } ?: uniqueId
}
Expand Down

0 comments on commit 664f482

Please sign in to comment.