Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

Expand t.co URLs and cleanup #21

Closed
sindresorhus opened this issue Dec 9, 2017 · 9 comments
Closed

Expand t.co URLs and cleanup #21

sindresorhus opened this issue Dec 9, 2017 · 9 comments
Labels
enhancement 🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt help wanted

Comments

@sindresorhus
Copy link
Owner

sindresorhus commented Dec 9, 2017

Issuehunt badges

We should expand the useless t.co redirects to the full URL. The full URL is available in the .js-display-url element.

We should also clean away query params like:

  • utm_source
  • utm_medium
  • utm_content
  • utm_campaign
  • utm_term
  • utm_id
  • ref=producthunt

Suggestions for additional ones are welcome!


IssueHunt Summary

sindresorhus sindresorhus has been rewarded.

Backers (Total: $60.00)

Submitted pull Requests


Tips

@fregante
Copy link
Contributor

@polomarcus
Copy link

Glad to read someone who has the same opinion as me on Twitter URL and UTMs 😊

I'll try to make a PR for this. I've done similar work for a chrome extension as well

https://dev.to/paulleclercq/twitter-without-short-links--1cig

@polomarcus
Copy link

Hi @sindresorhus

I would like to add my Mocha tests from my chrome extension to the projects, but I'm not sure how to add them.

Could you show me an example please ?

https://github.com/sindresorhus/refined-twitter/blob/master/test/index.js

@sindresorhus
Copy link
Owner Author

test.serial('should remove every t.co URLs with their real URLs', t => {
  const tweet = document.querySelector('#testExtension');
  tweet.setAttribute('href', 'http://t.co/fdmQ6yXo8G');

  tCoUrls();

  // Now we check that we do not have http://t.co/fdmQ6yXo8G anymore
  t.is(tweet.getAttribute('href'), 'http://www.wake-me-up.co');
});

More in the docs: https://github.com/avajs/ava

@kurtextrem
Copy link
Contributor

	function removeUtms(inputUrl) {
		var url = new URL(inputUrl)

		url.searchParams.forEach(function(value, key) {
			if (value.indexOf('utm_') !== -1 || key === 'ref' || key === 'affil' || key === 'zanpid')
				url.searchParams.delete(key)
		})

		return url.toString()
	}

This snippet is to clean utm_ etc. I wouldn't however clean ref=producthunt as many sites give special offers for ProductHunters

@IssueHuntBot
Copy link

@issuehuntfest has funded $60.00 to this issue. See it on IssueHunt

@IssueHuntBot
Copy link

@polomarcus has submitted a pull request. See it on IssueHunt

@issuehunt-oss issuehunt-oss bot added the 💵 Funded on Issuehunt This issue has been funded on Issuehunt label May 10, 2019
@issuehunt-oss
Copy link

issuehunt-oss bot commented Dec 1, 2020

@sindresorhus has rewarded $54.00 to @sindresorhus. See it on IssueHunt

  • 💰 Total deposit: $60.00
  • 🎉 Repository reward(0%): $0.00
  • 🔧 Service fee(10%): $6.00

@issuehunt-oss issuehunt-oss bot added 🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt and removed 💵 Funded on Issuehunt This issue has been funded on Issuehunt labels Dec 1, 2020
Repository owner locked and limited conversation to collaborators Dec 1, 2020
@sindresorhus
Copy link
Owner Author

Closing as this extension is now deprecated.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement 🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt help wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants