I have a workflow written in Alfred that when opening a URL location in AppleScript, the URL will be urlencoded() which effectively breaks:

open location "https://example.com/#hello" & selectedText

will open the URL https://example.com/%23hello.

The %23 should really stay #. How can this be achieved?

  • 1
    Try removing the / before the # character, or supply the name of the webpage between / and # character. – Nimesh Neema Dec 10 '18 at 15:57
  • Nimesch, that helps me a lot right now! Not sure if it solves the problem in a generic way though. If you want, please phrase it as an answer so I can vote it up. – Gabriel R. Dec 10 '18 at 16:13
  • 1
    Which browser are you using? I've just tested with Safari, Chrome, and Firefox and none give a problem opening a URL with an anchor (#). – Allan Dec 10 '18 at 16:13
  • I'm running this from Alfred as a custom workflow, opening in Safari. – Gabriel R. Dec 10 '18 at 16:15
  • 1
    It's very important you add the relevant details. So...it's Alfred that's doing this, not macOS or AppleScript per se. Can you open the URL properly via AppleScript only? This will confirm if it's an Alfred issue or a larger system wide issue on your machine. – Allan Dec 10 '18 at 16:19

This is because Alfred is encoding (UTF8) the URL.

enter image description here

Disable it and it will work.

  • I do not use Alfred but am curious to know if that's a global setting or a per workflow setting? – user3439894 Dec 10 '18 at 16:25
  • 1
    @user3439894 - That a "per query" setting. I believe it defaults to UTF8 – Allan Dec 10 '18 at 16:26
  • Ah... a "per query" setting, makes sense. +1 for the answer to the OP. – user3439894 Dec 10 '18 at 16:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .