Undoubling

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.

iOS Share Sheet

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:

Doubled URL 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.

WaPo URL workflow

The regex,

^(.+)\1$

looks for a stretch of characters that’s repeated once, (.+)\1. The anchors, ^ and $, 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, $1.

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.

Workflow action extension 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…


  1. It’s possible that regex greediness would prevent a small repeated substring from being captured even without the anchors, but I feel more comfortable using them.