That is NOT working for me.
For "YourURL" of:
https://www.somedomain.co.uk/
it returns:
www.somedomain.co.uk
I believe what the OP wants here is:
somedomain.co.uk
BTW, just for clarity, in the script the parameter:
'YourURL'
in the statement
.getvariable('YourURL')
refers to the KM Variable that contains the actual URL.