Relative Links in Safari

Hi all,

This might be too simple, but I didn’t find anything with the search.

I am trying to open a link in Safari with a script. The “open” or “open location” basically works, but the problem is that a part of the URL is some sort of session ID, i.e. different every time I open the website.

Is it possible to tell Safari to just open the site, i.e. to tell it to open “file.html” rather than “”?

Thanks a lot in advance.

If you can do it manually, then probably. If you can’t, then probably not. But it should be possible to find the current link in the source code, either using JavaScript or something like this:

tell application "Safari" to set srce to source of front document

set linkURL to (do shell script ("<<<" & quoted form of srce & " grep -Eo '[^/]+/file.html'"))

Cool, thanks for that. I’ll see what I can do with that.