Skip to content

Commit

Permalink
Add nameToId() function
Browse files Browse the repository at this point in the history
  • Loading branch information
ILIYANGERMANOV committed Dec 22, 2024
1 parent da5b477 commit 437772d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android.nonTransitiveRClass=true
# Pomfile definitions
GROUP=com.ivy-apps
POM_ARTIFACT_ID=learn-content-dsl
VERSION_NAME=0.0.5
VERSION_NAME=0.0.6
SONATYPE_HOST=CENTRAL_PORTAL
RELEASE_SIGNING_ENABLED=true
POM_DESCRIPTION=Ivy Learn DSL for creating interactive lessons.
Expand Down
8 changes: 8 additions & 0 deletions learn-content-dsl/src/commonMain/kotlin/ivy/learn/Util.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package ivy.learn

fun nameToId(name: String): String = name
.lowercase()
.replace(Regex("[^a-z0-9\\s-]"), "") // Remove invalid characters
.replace("\\s+".toRegex(), "-") // Replace spaces with dashes
.replace("-+".toRegex(), "-") // Replace multiple dashes with a single dash
.trim('-') // Remove leading and trailing dashes

0 comments on commit 437772d

Please sign in to comment.