Gary King Posted May 15 Share Posted May 15 I'm passing a URL to "Open URL" to open. The URL has an ampersand that I want to encode, because otherwise it's treated as part of the URL's query string. However, when I encode it as %26, Alfred encodes that again, therefore making it %2526. How can I stop Alfred from encoding it a second time? Link to comment
vitor Posted May 15 Share Posted May 15 How are you passing the URL? The Open URL object has checkboxes regarding what it encodes; untick what you don’t need. Link to comment
Gary King Posted May 15 Author Share Posted May 15 4 hours ago, vitor said: How are you passing the URL? The Open URL object has checkboxes regarding what it encodes; untick what you don’t need. I've attached a screenshot below. The checkboxes shouldn't matter since I'm using neither placeholder. In any case, I tested by unchecking them, and nothing changed. Link to comment
vitor Posted May 15 Share Posted May 15 Please provide a short example workflow so I can better understand your issue and how to solve it. Link to comment
Gary King Posted May 15 Author Share Posted May 15 (edited) 30 minutes ago, vitor said: Please provide a short example workflow so I can better understand your issue and how to solve it. I've attached the test workflow (in the next post) Here are the issues: %0A (for a newline) gets added to the end of the URL, when I thought Alfred should trim URLs before opening them. it seems impossible to pass an ampersand as a query string, since Alfred replaces the %26 with %2526 As you can see, in the script, I open the URL https://example.com/?query=a%26b But Alfred opens https://example.com/?query=a%2526b%0A instead. Edited May 15 by Gary King Link to comment
Gary King Posted May 15 Author Share Posted May 15 Sorry, I didn't realize that I can't attach workflows to posts. I've linked to the workflow here. Link to comment
vitor Posted May 15 Share Posted May 15 It is the newline which is causing the issue. You can verify this by using a Transform Utility to trim whitespace before passing it to the Open URL, or by appending | tr -d '\n' (which deletes newlines) to the command in the Run Script. You should be able to do the same by having the script not output a newline at the end. With that, the encoding works as expected. I’ll think about it a bit and discuss internally but I’m betting this may be intentional (the Open URL object has existed for a long time). When faced with an entity which has to be encoded (the newline) but isn’t, it makes sense to assume the URL isn’t encoded. Link to comment
Gary King Posted May 15 Author Share Posted May 15 Thanks, I learned a lot. I've been writing Alfred workflows for a long time, but now I've realized that I've always used Script Filter and output JSON, with arg set to a URL, so Alfred would always read it perfectly. vitor 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now