A predesigned Automator AppleScript variable has no effect

I built the following workflow. It creates a text file from selected text in Safari.

===Beginning of the workflow===

in: Workflow receives selected text in Safari as input

Action #1. “New Text File”:

File Format same as input text
Save as “Selected from the web-page [in the square brackets there’s an Automator built-in variable of type ‘AppleScript’ containing the script:
tell app “Safari”
tell window 1
set TabUrl (the url of the current tab) as text
return TabUrl
end tell
end tell
’]”->Variable’s name is ‘TabUrl’

Where: a chosen folder – chosen by the user
Encoding: Unicode UTF-8

Action #2. Ask for Confirmation (whether the created file should be opened immediately)

Action #3. Open Finder items with the default application.

===End of the workflow====

My problem is the variable TabUrl placed inside the name field for the file to be created. It’s meant to return just plain text, in this case, it’s the URL of the current tab where the selection has been made, with the URL then coerced into text. However, upon passing through this action the resulting name omits the output of the AppleScript, although the script is correct and works as expected by itself. Is it because of the special symbols “/” and “:”? But I renamed the file manually in Finder and the system successfully changed the one and only colon in the URL string to “/” leaving the rest in place. I tried enclosing the result in quotes, then tried to replace “:” with “/” - to no avail.
At the same time when I tried to feed it the name of the current tab instead of the URL it worked.
So, what’s going on there and why such a simple snippet of AppleScript script refuses to run in Automator?

Model: MacBook Pro
AppleScript: 2.7
Browser: Safari 605.1.15
Operating System: macOS 10.13