December 24, 2017 at 9:33 AM by Dr. Drang
There are some weird things going on with iOS’s Copy item in the Share Sheet. I made a short Workflow to get around a problem I’ve been having with it when trying to share the URL of a Washington Post story.
I mentioned the problem on Twitter a few weeks ago: I’m reading an article in the WaPo app that I want to link to. I bring up the Share Sheet, tap Copy, and switch to some other app I want to paste the URL into. Could be Drafts, Notes, Slack, Textastic—whatever. I then paste the URL and wait to see what happens. Depending on the app, I might get exactly what I expect (Notes and Textastic), or I might get a doubled version of the URL (Drafts and Slack). Here’s an example in Drafts:
After I tweeted about this, Chad Moone, a WaPo developer, got in touch with me about it. A lot of it has to do with internal changes Apple made in how Copy works. He thought they’d fixed the problem, but apparently they hadn’t tested their fix across enough apps. And other people have told me it’s not just a WaPo problem, although that’s the only place I’ve run into it.
After weeks of frustratedly selecting and backspacing to delete the redundant text, I decided to make a Workflow to do it for me. It’s only two steps: a regex replacement followed by a save to the clipboard.
looks for a stretch of characters that’s repeated once,
(.+)\1. The anchors,
$, ensure that we capture the whole repeated URL, not just some small substring in the middle of it.1 It then replaces the whole string with just one copy of the repeated part,
Now when I want to share a link to an article, I tap Run Workflow instead of Copy and choose WaPo URL from the list.
I see I may need to trim my list of action extensions, and I definitely need to be more liberal in my use of colors. I won’t be changing the color of the WaPo URL workflow, though, because a newspaper is black and white and…