global-functions: $CleanName: do not start with a dash

This commit is contained in:
Christian Hesse 2024-04-23 14:50:57 +02:00
parent b0f58696f3
commit 755db5d66d

View file

@ -230,12 +230,20 @@
:for I from=0 to=([ :len $Input ] - 1) do={ :for I from=0 to=([ :len $Input ] - 1) do={
:local Char [ :pick $Input $I ]; :local Char [ :pick $Input $I ];
:if ([ :typeof [ find "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-" $Char ] ] = "nil") do={ :if ([ :typeof [ find "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-" $Char ] ] = "nil") do={
:do {
:if ([ :len $Return ] = 0) do={
:error true;
}
:if ([ :pick $Return ([ :len $Return ] - 1) ] = "-") do={
:error true;
}
:set Char "-"; :set Char "-";
} on-error={
:set Char "";
}
} }
:if ($Char != "-" || [ :pick $Return ([ :len $Return ] - 1) ] != "-") do={
:set Return ($Return . $Char); :set Return ($Return . $Char);
} }
}
:return $Return; :return $Return;
} }