Editorial Workflows

Remove UTM

unlisted workflow

Install Workflow...

This workflow contains at least one Python script. Only use it if you trust the person who shared this with you, and if you know exactly what it does.

I understand, install the workflow!

This is a workflow for Editorial, a Markdown and plain text editor for iOS. To download it, you need to view this page on a device that has the app installed.

Description: Cleans up URLs by removing UTM parameters.

Shared by: viticci

Comments: Comment Feed (RSS)

anonymous — 29 May 2014
Where does the Input value come from? My clipboard, selected text, or anything that looks like a URL in my note?

+ Add Comment

Workflow Preview
Set Variable ?
Variable Name
url
Value
Input
If… ?
Run the block if
url
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
Set Variable ?
Variable Name
url
Value
Browser URL
…End If
Generate Text ?
Text
url
If… ?
Run the block if
url
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
Run Python Script ?
Source Code
from urlparse import parse_qs, urlsplit, urlunsplit
from urllib import urlencode
from cgi import escape
import workflow

# Based on: http://blog.maexotic.de/archives/215-Those-evil-utm_-parameters-....html

url = workflow.get_input()

res = urlsplit(url)
if not res.query:
	workflow.set_output(url)
qdict = parse_qs(res.query)
map(lambda key: qdict.pop(key), filter(lambda key: key.startswith('utm_'), qdict.keys()))
res = list(res)
res[3] = escape(urlencode(qdict, doseq=1))
workflow.set_output(urlunsplit(res))
…End If