Friday, October 22, 2021

#1 2021-07-21 06:07:12 am

Fredrik71
Member
Registered: 2019-10-23
Posts: 901

Quick way to strip a Google URL to a flat URL

When we copy a Google URL we get more what we want.

This simple example show how we could remove it with plain Vanilla AppleScript.

Applescript:

-- Google string
set theString to "https://www.google.com/url?q=https://developer.apple.com/documentation/objectivec/nsobject/1412787-addobserver&sa=U&ved=2ahUKEwiX6sOygvTxAhWCrYsKHaslAbMQFjABegQICRAB&usg=AOvVaw2_CjFXYTNqAGWk3IsLfYpk"

return its flatURLFromGoogleURL(theString, {"https://www.google.com/url?q=", "&"})

on flatURLFromGoogleURL(inputString, {theBeginString, theEndString})
   set theEndString to text (offset of theEndString in inputString) thru -1 of inputString
   set AppleScript's text item delimiters to {theBeginString, theEndString}
   set theResult to text items of inputString
   set text item delimiters to ""
   return theResult as text
end flatURLFromGoogleURL


if you are the expert, who will you call if its not your imagination.

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)