Remove utm params from share URLs

pull/1657/head
Kamran Ahmed 5 years ago
parent 1963c06226
commit d41ac9205e
  1. 33
      lib/url.js
  2. 1
      package.json
  3. 19
      yarn.lock

@ -1,4 +1,3 @@
import queryString from 'query-string';
import siteConfig from 'storage/site'; import siteConfig from 'storage/site';
export const prefixHost = (url) => { export const prefixHost = (url) => {
@ -12,41 +11,17 @@ export const getTwitterUrl = (username) => {
}; };
export const getTwitterShareUrl = ({ text, url }) => { export const getTwitterShareUrl = ({ text, url }) => {
const urlToShare = `${prefixHost(url)}?${queryString.stringify({ return `https://twitter.com/intent/tweet?text=${text}&url=${encodeURI(prefixHost(url))}`;
utm_source: 'roadmap.sh',
utm_campaign: 'share',
utm_medium: 'twitter',
})}`;
return `https://twitter.com/intent/tweet?text=${text}&url=${encodeURI(urlToShare)}`;
}; };
export const getFacebookShareUrl = ({ text, url }) => { export const getFacebookShareUrl = ({ text, url }) => {
const urlToShare = `${prefixHost(url)}?${queryString.stringify({ return `https://www.facebook.com/sharer/sharer.php?quote=${text}&u=${encodeURI(prefixHost(url))}`;
utm_source: 'roadmap.sh',
utm_campaign: 'share',
utm_medium: 'facebook',
})}`;
return `https://www.facebook.com/sharer/sharer.php?quote=${text}&u=${encodeURI(urlToShare)}`;
}; };
export const getRedditShareUrl = ({ text, url }) => { export const getRedditShareUrl = ({ text, url }) => {
const urlToShare = `${prefixHost(url)}?${queryString.stringify({ return `https://www.reddit.com/submit?title=${text}&url=${encodeURI(prefixHost(url))}`;
utm_source: 'roadmap.sh',
utm_campaign: 'share',
utm_medium: 'reddit'
})}`;
return `https://www.reddit.com/submit?title=${text}&url=${encodeURI(urlToShare)}`;
}; };
export const getHnShareUrl = ({ text, url }) => { export const getHnShareUrl = ({ text, url }) => {
const urlToShare = `${prefixHost(url)}?${queryString.stringify({ return `https://news.ycombinator.com/submitlink?t=${text}&u=${prefixHost(url)}`;
utm_source: 'roadmap.sh',
utm_campaign: 'share',
utm_medium: 'hn'
})}`;
return `https://news.ycombinator.com/submitlink?t=${text}&u=${urlToShare}`;
}; };

@ -35,7 +35,6 @@
"node-sass": "^4.12.0", "node-sass": "^4.12.0",
"postcss-css-variables": "^0.13.0", "postcss-css-variables": "^0.13.0",
"prism-themes": "^1.3.0", "prism-themes": "^1.3.0",
"query-string": "^6.8.3",
"react": "^16.9.0", "react": "^16.9.0",
"react-dom": "^16.9.0", "react-dom": "^16.9.0",
"styled-components": "^4.4.0" "styled-components": "^4.4.0"

@ -6920,15 +6920,6 @@ query-string@^4.1.0:
object-assign "^4.1.0" object-assign "^4.1.0"
strict-uri-encode "^1.0.0" strict-uri-encode "^1.0.0"
query-string@^6.8.3:
version "6.8.3"
resolved "https://registry.yarnpkg.com/query-string/-/query-string-6.8.3.tgz#fd9fb7ffb068b79062b43383685611ee47777d4b"
integrity sha512-llcxWccnyaWlODe7A9hRjkvdCKamEKTh+wH8ITdTc3OhchaqUZteiSCX/2ablWHVrkVIe04dntnaZJ7BdyW0lQ==
dependencies:
decode-uri-component "^0.2.0"
split-on-first "^1.0.0"
strict-uri-encode "^2.0.0"
querystring-es3@^0.2.0: querystring-es3@^0.2.0:
version "0.2.1" version "0.2.1"
resolved "https://registry.yarnpkg.com/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73" resolved "https://registry.yarnpkg.com/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73"
@ -7796,11 +7787,6 @@ spdx-license-ids@^3.0.0:
resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.5.tgz#3694b5804567a458d3c8045842a6358632f62654" resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.5.tgz#3694b5804567a458d3c8045842a6358632f62654"
integrity sha512-J+FWzZoynJEXGphVIS+XEh3kFSjZX/1i9gFBaWQcB+/tmpe2qUsSBABpcxqxnAxFdiUFEgAX1bjYGQvIZmoz9Q== integrity sha512-J+FWzZoynJEXGphVIS+XEh3kFSjZX/1i9gFBaWQcB+/tmpe2qUsSBABpcxqxnAxFdiUFEgAX1bjYGQvIZmoz9Q==
split-on-first@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/split-on-first/-/split-on-first-1.1.0.tgz#f610afeee3b12bce1d0c30425e76398b78249a5f"
integrity sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==
split-string@^3.0.1, split-string@^3.0.2: split-string@^3.0.1, split-string@^3.0.2:
version "3.1.0" version "3.1.0"
resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2" resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2"
@ -7912,11 +7898,6 @@ strict-uri-encode@^1.0.0:
resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz#279b225df1d582b1f54e65addd4352e18faa0713" resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz#279b225df1d582b1f54e65addd4352e18faa0713"
integrity sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM= integrity sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM=
strict-uri-encode@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546"
integrity sha1-ucczDHBChi9rFC3CdLvMWGbONUY=
string-hash@1.1.3: string-hash@1.1.3:
version "1.1.3" version "1.1.3"
resolved "https://registry.yarnpkg.com/string-hash/-/string-hash-1.1.3.tgz#e8aafc0ac1855b4666929ed7dd1275df5d6c811b" resolved "https://registry.yarnpkg.com/string-hash/-/string-hash-1.1.3.tgz#e8aafc0ac1855b4666929ed7dd1275df5d6c811b"

Loading…
Cancel
Save