Skip to content

Commit

Permalink
♻️ added noopener
Browse files Browse the repository at this point in the history
  • Loading branch information
harshzalavadiya committed Dec 25, 2020
1 parent 9ab52e7 commit 0dd509c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "react-web-share",
"author": "Harsh Zalavadiya",
"version": "1.0.15",
"version": "1.0.16",
"license": "MIT",
"repository": "harshzalavadiya/react-web-share",
"module": "dist/react-web-share.esm.js",
Expand Down
18 changes: 10 additions & 8 deletions src/components/icon/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,51 @@ export interface IconListType {
};
}

const externalOpen = (URL) => window.open(URL, "_blank", "noopener");

const iconList: IconListType = {
facebook: {
path: (
<path d="M24 12a12 12 0 10-13.9 11.9v-8.4h-3V12h3V9.4c0-3 1.8-4.7 4.6-4.7l2.6.2v3h-1.5c-1.5 0-2 .9-2 1.8V12h3.4l-.5 3.5h-2.8v8.4A12 12 0 0024 12z" />
),
color: "#0076FB",
e: l => window.open(`https://www.facebook.com/sharer/sharer.php?u=${l}`),
e: (l) => externalOpen(`https://www.facebook.com/sharer/sharer.php?u=${l}`),
},
twitter: {
path: (
<path d="M24 4.6a10 10 0 01-2.9.7 5 5 0 002.2-2.7c-1 .6-2 1-3.1 1.2a5 5 0 00-8.4 4.5A14 14 0 011.6 3.2 4.8 4.8 0 001 5.6a5 5 0 002.2 4.1 4.9 4.9 0 01-2.3-.6A5 5 0 005 14a5 5 0 01-2.2 0 5 5 0 004.6 3.5 9.9 9.9 0 01-6.1 2.1H0a14 14 0 007.6 2.2c9 0 14-7.5 14-14V7A10 10 0 0024 4.6z" />
),
color: "#1DA1F2",
e: (l, t) => window.open(`https://twitter.com/intent/tweet?text=${t}&url=${l}`),
e: (l, t) => externalOpen(`https://twitter.com/intent/tweet?text=${t}&url=${l}`),
},
whatsapp: {
path: (
<path d="M17.5 14.4l-2-1c-.3 0-.5-.1-.7.2l-1 1.1c-.1.2-.3.3-.6.1s-1.3-.5-2.4-1.5a9 9 0 01-1.7-2c-.1-.3 0-.5.2-.6l.4-.6c.2-.1.2-.3.3-.5v-.5L9 7c-.2-.6-.4-.5-.6-.5h-.6c-.2 0-.5 0-.8.4-.2.3-1 1-1 2.5s1 2.8 1.2 3c.2.2 2.1 3.2 5.1 4.5l1.7.6a4 4 0 001.9.2c.5-.1 1.7-.8 2-1.5.2-.6.2-1.2.1-1.4l-.5-.3M12 21.8a9.9 9.9 0 01-5-1.4l-.4-.2-3.7 1 1-3.7-.2-.3a9.9 9.9 0 01-1.5-5.3 9.9 9.9 0 0116.8-7 9.8 9.8 0 013 7 9.9 9.9 0 01-10 9.9m8.4-18.3A11.8 11.8 0 0012.1 0 12 12 0 001.8 17.8L0 24l6.4-1.6a11.9 11.9 0 005.6 1.4 12 12 0 0012-11.9 11.8 11.8 0 00-3.5-8.4z" />
),
color: "#25D366",
e: (l, t) => window.open(`https://api.whatsapp.com/send?text=${t} ${l}`),
e: (l, t) => externalOpen(`https://api.whatsapp.com/send?text=${t} ${l}`),
},
reddit: {
path: (
<path d="M12 0A12 12 0 000 12a12 12 0 0012 12 12 12 0 0012-12A12 12 0 0012 0zm5.01 4.74c.69 0 1.25.56 1.25 1.25a1.25 1.25 0 01-2.5.06l-2.6-.55-.8 3.75c1.83.07 3.48.63 4.68 1.49.3-.31.73-.5 1.2-.5.97 0 1.76.8 1.76 1.76 0 .72-.43 1.33-1.01 1.61a3.11 3.11 0 01.04.52c0 2.7-3.13 4.87-7 4.87-3.88 0-7-2.17-7-4.87 0-.18 0-.36.04-.53A1.75 1.75 0 014.03 12a1.75 1.75 0 012.96-1.26 8.52 8.52 0 014.74-1.5l.89-4.17a.34.34 0 01.14-.2.35.35 0 01.24-.04l2.9.62a1.21 1.21 0 011.11-.7zM9.25 12a1.25 1.25 0 101.25 1.25c0-.69-.56-1.25-1.25-1.25zm5.5 0a1.25 1.25 0 000 2.5 1.25 1.25 0 000-2.5zm-5.47 3.99a.33.33 0 00-.23.1.33.33 0 000 .46c.84.84 2.49.91 2.96.91.48 0 2.1-.06 2.96-.91a.36.36 0 00.03-.47.33.33 0 00-.46 0c-.55.54-1.68.73-2.51.73-.83 0-1.98-.2-2.51-.73a.33.33 0 00-.24-.1z" />
),
color: "#FF4500",
e: (l, t) => window.open(`https://www.reddit.com/submit?url=${l}&title=${t}`),
e: (l, t) => externalOpen(`https://www.reddit.com/submit?url=${l}&title=${t}`),
},
telegram: {
path: (
<path d="M23.91 3.79L20.3 20.84c-.25 1.21-.98 1.5-2 .94l-5.5-4.07-2.66 2.57c-.3.3-.55.56-1.1.56-.72 0-.6-.27-.84-.95L6.3 13.7.85 12c-1.18-.35-1.19-1.16.26-1.75l21.26-8.2c.97-.43 1.9.24 1.53 1.73z" />
),
color: "#0088CC",
e: (l, t) => window.open(`https://telegram.me/share/msg?url=${l}&text=${t}`),
e: (l, t) => externalOpen(`https://telegram.me/share/msg?url=${l}&text=${t}`),
},
linkedin: {
path: (
<path d="M6.5 21.5h-5v-13h5v13zM4 6.5C2.5 6.5 1.5 5.3 1.5 4s1-2.4 2.5-2.4c1.6 0 2.5 1 2.6 2.5 0 1.4-1 2.5-2.6 2.5zm11.5 6c-1 0-2 1-2 2v7h-5v-13h5V10s1.6-1.5 4-1.5c3 0 5 2.2 5 6.3v6.7h-5v-7c0-1-1-2-2-2z" />
),
color: "#0073b1",
e: (l, t, ti) =>
window.open(
externalOpen(
`https://www.linkedin.com/shareArticle?mini=true&url=${l}&title=${ti}&summary=${t}`
),
},
Expand All @@ -60,14 +62,14 @@ const iconList: IconListType = {
<path d="M20 4H4a2 2 0 00-2 2v12c0 1.1.9 2 2 2h16a2 2 0 002-2V6a2 2 0 00-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z" />
),
color: "#E53E3E",
e: (l, t) => window.open(`mailto:?body=${l}&subject=${t}`),
e: (l, t) => externalOpen(`mailto:?body=${l}&subject=${t}`),
},
copy: {
path: (
<path d="M16 1H4a2 2 0 00-2 2v14h2V3h12V1zm3 4H8a2 2 0 00-2 2v14c0 1.1.9 2 2 2h11a2 2 0 002-2V7a2 2 0 00-2-2zm0 16H8V7h11v14z" />
),
color: "#718096",
e: l => navigator.clipboard.writeText(decodeURIComponent(l)),
e: (l) => navigator.clipboard.writeText(decodeURIComponent(l)),
},
};

Expand Down

0 comments on commit 0dd509c

Please sign in to comment.