diff options
author | Christian Hesse <mail@eworm.de> | 2024-04-23 14:50:57 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2024-04-29 23:02:48 +0200 |
commit | 755db5d66db8e24872fb7bf959e09b047f7cd5f9 (patch) | |
tree | b0c6c60aab3c31c38778bd9d9256263748f626fa /global-functions.rsc | |
parent | b0f58696f334c9c378229f68f7e5e6d69a4b6af7 (diff) |
global-functions: $CleanName: do not start with a dash
Diffstat (limited to 'global-functions.rsc')
-rw-r--r-- | global-functions.rsc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/global-functions.rsc b/global-functions.rsc index b0bde7e..5135fc1 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -230,11 +230,19 @@ :for I from=0 to=([ :len $Input ] - 1) do={ :local Char [ :pick $Input $I ]; :if ([ :typeof [ find "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-" $Char ] ] = "nil") do={ - :set Char "-"; - } - :if ($Char != "-" || [ :pick $Return ([ :len $Return ] - 1) ] != "-") do={ - :set Return ($Return . $Char); + :do { + :if ([ :len $Return ] = 0) do={ + :error true; + } + :if ([ :pick $Return ([ :len $Return ] - 1) ] = "-") do={ + :error true; + } + :set Char "-"; + } on-error={ + :set Char ""; + } } + :set Return ($Return . $Char); } :return $Return; } |