From 6fd0becf64184184642e719e288bc537a0bee499 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 19 Apr 2024 08:59:51 +0200 Subject: global-functions: introduce $ProtocolStrip --- global-functions.rsc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/global-functions.rsc b/global-functions.rsc index 918ea9a..3b9f27c 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -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 ]; -- cgit v1.2.3-54-g00ecf