1
0
mirror of https://github.com/eworm-de/routeros-scripts.git synced 2024-05-11 05:55:19 +00:00

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,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;
}