kerim Posted July 24, 2017 Share Posted July 24, 2017 I'm writing a workflow that uses Bear's x-callback-url scheme. I got it to work, but I keep running into problems when my text contains certain ASCII. For instance, I have to write %23 instead of # or it won't work. Is there some way to automate this, so that the final output is properly escaped? I searched but couldn't find anything. Thanks! Link to comment
kerim Posted July 24, 2017 Author Share Posted July 24, 2017 UPDATE: I found a workflow to encode/decode text which handles URL encoding, however it doesn't output the results in the format I need. I've opened an issue for that on Github Link to comment
vitor Posted July 24, 2017 Share Posted July 24, 2017 We can’t properly help you without access to your Workflow. Debugging can already be hard with access to the code, and you’re asking us to guess yours from a description. There are multiple places where you code or Workflow setup may be going wrong. There are multiple ways to url encode a string, but we don’t even know what language you’re using. Without looking at it we’re shooting in the dark, which is a waste of time for everyone involved (including you). Read the Reporting Problems with Workflows topic, as it gives a nice overview on how to build an effective report. Link to comment
deanishe Posted July 24, 2017 Share Posted July 24, 2017 3 hours ago, kerim said: I'm writing a workflow that uses Bear's x-callback-url scheme. I got it to work, but I keep running into problems when my text contains certain ASCII. For instance, I have to write %23 instead of # or it won't work. Is there some way to automate this, so that the final output is properly escaped? I searched but couldn't find anything. Thanks! You need to URL-encode anything you stick in a URL. If you're using a real programming language, it almost certainly has a function to do that. If you want more actionable help, please follow @vitor's advice. Link to comment
kerim Posted July 24, 2017 Author Share Posted July 24, 2017 Thank you everyone for the quick responses. Here's a link to the workflow. But the reason I didn't share it is that I'm not a programmer and I've just created this by merging two scripts I found that were written by other people. I would rather just know the best practice for doing this rather than trying to fix this code, as I've probably made things much more complicated than they need to be if you actually know what you are doing. I just need to take the output of some text and URL-encode it before passing it on to the URL. I am happy to use examples from any "real programming language" if anyone has any suggestions for a simple way to do this. Thanks! Link to comment
deanishe Posted July 24, 2017 Share Posted July 24, 2017 (edited) Here's a fixed version. I've ripped out all the PHP stuff. That was completely broken, as it was a Script Filter script designed to show results in Alfred. It would not work the way you want. I've left in the normalise command, though I'm not sure it's necessary. What I added was a single Run Script action to URL-encode the input. Edited July 24, 2017 by deanishe Fix link Link to comment
deanishe Posted July 24, 2017 Share Posted July 24, 2017 1 hour ago, kerim said: the reason I didn't share it is that I'm not a programmer and I've just created this by merging two scripts I found that were written by other people TBH, that's more of a reason to share. It's more likely there'll be other issues. As noted, you were using the wrong kind of script. No amount of URL-encoding could have made that workflow work because the script you'd repurposed wrapped the encoded text in XML. Link to comment
kerim Posted July 24, 2017 Author Share Posted July 24, 2017 Thanks so much! Unfortunately there is something weird about the link you posted, while my mouse turns to a pointer over all the other links, somehow that one isn't registering as a link for me, so I can't download the file. Link to comment
deanishe Posted July 24, 2017 Share Posted July 24, 2017 I've fixed the link. Sorry about that. This forum software is riddled with bugs. Link to comment
kerim Posted July 24, 2017 Author Share Posted July 24, 2017 Thanks so much @deanishe! I got it working. As you say, the normalise command does not seem to matter. One strange thing that someone might want to look into is that it did not work if it was set to "Chrome" but did work if it was set to Safari, or set to the "default browser" - even if the default browser is Chrome! Link to comment
deanishe Posted July 24, 2017 Share Posted July 24, 2017 1 hour ago, kerim said: One strange thing It's not strange at all. Why would you expect Chrome (or any web browser) to be able to open a bear:// URL? It's entirely meaningless to any application except Bear. You should use "default browser" and nothing else. The system will look which application is registered for the bear:// scheme and pass the URL to that application. Not to a web browser. They're for http(s):// URLs. Link to comment
kerim Posted July 24, 2017 Author Share Posted July 24, 2017 " Why would you expect Chrome (or any web browser) to be able to open a bear:// URL? It's entirely meaningless to any application except Bear." You seem to think it laughable that someone would not understand the difference between "the default browser" and the actual default browser. I really appreciate all the time you've taken to help me out, but I don't consider this laughable or obvious at all. Link to comment
deanishe Posted July 24, 2017 Share Posted July 24, 2017 1 hour ago, kerim said: You seem to think it laughable that someone would not understand the difference between "the default browser" and the actual default browser. Hardly. kerim 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