Skip to content

Commit 256f67f

Browse files
fix URI encode issues (#9)
* fix URI decode issues * replace decodeURIComponent with encodeURIComponent * ♻️ lint fix Co-authored-by: Harsh Zalavadiya <harsh@foobars.in>
1 parent 61ec62c commit 256f67f

File tree

4 files changed

+7
-9
lines changed

4 files changed

+7
-9
lines changed

src/components/icon/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ export default function Icon({ name, data, onClose }: IconProps) {
1919

2020
return (
2121
<button
22-
onClick={() => e(data.url, data.text, data.title) && onClose()}
22+
onClick={() => e(encodeURIComponent(data.url), data.text, data.title) && onClose()}
2323
aria-label={name}
2424
style={{ ...SocialIconStyle, background: color }}
2525
>
26-
<svg xmlns="http://www.w3.org/2000/svg" fill="white" viewBox={viewBox}>
26+
<svg fill="white" viewBox={viewBox}>
2727
{path}
2828
</svg>
2929
</button>

src/components/icon/list.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const iconList: IconListType = {
2222
<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" />
2323
),
2424
color: "#1DA1F2",
25-
e: (l, t) => window.open(`http://twitter.com/intent/tweet?text=${t}&url=${l}`),
25+
e: (l, t) => window.open(`https://twitter.com/intent/tweet?text=${t}&url=${l}`),
2626
},
2727
whatsapp: {
2828
path: (
@@ -36,7 +36,7 @@ const iconList: IconListType = {
3636
<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" />
3737
),
3838
color: "#FF4500",
39-
e: (l, t) => window.open(`http://www.reddit.com/submit?url=${l}&title=${t}`),
39+
e: (l, t) => window.open(`https://www.reddit.com/submit?url=${l}&title=${t}`),
4040
},
4141
telegram: {
4242
path: (

src/index.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ export const RWebShare = ({ children, data, sites = Object.keys(iconList) }: RWe
1515
...data,
1616
title: data.title || "share",
1717
text: data.text || "",
18-
url: encodeURIComponent(
19-
data.url || (typeof window !== "undefined" && window.location.href) || ""
20-
),
18+
url: data.url || (typeof window !== "undefined" && window.location.href) || "",
2119
}),
2220
[data]
2321
);

src/interfaces.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ export interface RWebShareProps {
1313
export interface SocialIconsProps {
1414
onClose;
1515
sites: string[];
16-
data: ShareData;
16+
data: Required<ShareData>;
1717
}
1818

1919
export interface IconProps {
2020
onClose;
2121
name: string;
22-
data: ShareData;
22+
data: Required<ShareData>;
2323
}

0 commit comments

Comments
 (0)