Workflow in Drafts: How to Encode URL using Launch Center Pro's Clipboard Action

As you learn more about creating your own URL schemes, you will want to try to create a chain of actions. Each time you create a chain, you need to encode the URL of the second action. Both Drafts 2.5 and Launch Center Pro 1.1 have included a syntax that lets you encode the URL easily, i.e. by using the curly brackets, {{..}}.

The problem with the curly brackets is that it is limited only to the second URL. If you're creating a chain of action that involves a third URL, you need to encode the third URL manually. Even though there is already a great web service that lets you encode or decode a URL, it's simply not practical enough to be used while you're writing your code on your iPhone.

Fortunately, Launch Center Pro 1.1 has a new feature that allows you to convert the text format of your clipboard content, including encoding or decoding it. All you need to do is to transfer your coding to the clipboard and have Launch Center Pro convert it.

This is a custom URL action for Drafts that allows you to convert the contents of [[draft]] using Launch Center Pro's urlencode function, store the result in your Clipboard, and return to Drafts upon completion.

Code your URL schemes inside Drafts and use the "Create URL Action" to automatically import it as a new URL action in Drafts.

Requires: Drafts 2.5, Launch Center Pro 1.1

Open this link on your iOS device to have it automatically installed in Drafts.

As you can see from the example above, the chain of actions has three URLs. The first one is to copy the [[draft]] contents into the Clipboard. The second one is to call Launch Center Pro and have it encode the Clipboard's contents. And, the third one is the URL that allows you to return to Drafts upon completion. You don't need to encode the first URL, but you need to encode the second URL and double-encode the third URL. To keep the code readable, the curly brackets really help. But, you still need to encode the last URL inside the curly brackets.

Simply changing the format from urlencode to urldecode allows you to create a separate URLDecode action. To save time, you can also choose to open this link on your iOS device to have the URLDecode Draft to Clipboard action installed in Drafts.

Note: I have created an updated version where you can return to Drafts and have the new encoded URL pasted as a new Drafts post. It's included as part of a tutorial that I wrote to help you understand when Drafts and Launch Center Pro are translating their supported tags.

To find my other workflows and tutorials, please visit my Productivity and Workflows blog.