Zettt / LaunchBar-Scripts

Scripts for LaunchBar, Alfred, Keyboard Maestro and more.
http://www.macosxscreencasts.com
165 stars 20 forks source link

Expand Short URL should remove things like m.url.com or mobile.url.com #5

Closed Zettt closed 10 years ago

patrickwelker commented 10 years ago

Visit alfred-workflows/LinkClean/info.plist at master · vitorgalvao/alfred-workflows by @vitorgalvao and integrate his regex: # remove 'm.' 'mobile.' 'touch.', 'utm' 'ref' url=$(echo "${url}" | perl -pe 's/(http[s]?:\/\/)(m\.|mobile\.|touch\.)(.*)/\1\3/;s/([?&]utm.*|[?&]ref.*)//')

Zettt commented 10 years ago

Oh nice. So, he's also removing Google Analytics tracking in one fell swoop too. I kinda like that. I'm not so sure about the mobile stuff.

Zettt commented 10 years ago

@pattulus Do you have an example email I could try this with? Essentially this is a Keyboard Maestro macro that includes this change:

Execute Shell Script curl -sILpbpaste| grep ^[lL]ocation | cut -c 11- | perl -pe 's/(http[s]?:\/\/)(m\.|mobile\.|touch\.)(.*)/\1\3/;s/([?&]utm.*|[?&]ref.*)//') | pbcopy

http://cl.ly/image/1N2O2K180n3v

Does that work for you?

Zettt commented 10 years ago

Update on this. I'm closing this. Decision is as follows:

It is not this scripts job to "clean up" things, this script expands a given short URL only. Cleaning up a link doesn't make the expansion faster/better/whatever, therefore it is irrelevant. I might be adding this as an option in my New Link macro in @Zettt/km-markdown-library#31 though.

Case closed.