global-functions: introduce $ProtocolStrip

This commit is contained in:
Christian Hesse 2024-04-19 08:59:51 +02:00
parent b50a5b294a
commit 6fd0becf64

View file

@ -58,6 +58,7 @@
:global ParseDate;
:global ParseKeyValueStore;
:global PrettyPrint;
:global ProtocolStrip;
:global RandomDelay;
:global RequiredRouterOS;
:global ScriptFromTerminal;
@ -885,6 +886,17 @@
:put [ $Unix2Dos $Input ];
}
# strip protocol from from url string
:set ProtocolStrip do={
:local Input [ :tostr $1 ];
:local Pos [ :find $Input "://" ];
:if ([ :typeof $Pos ] = "nil") do={
:return $Input;
}
:return [ :pick $Input ($Pos + 3) [ :len $Input ] ];
}
# delay a random amount of seconds
:set RandomDelay do={
:local Time [ :tonum $1 ];