Skip to content

Commit 023e9ba

Browse files
authored
add missing encodeURIComponent()
1 parent 8d25211 commit 023e9ba

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/share.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ navigator.share = navigator.share || (function () {
530530
function bindEvents() {
531531
Array.from(container.querySelectorAll('.tool-icon')).forEach(tool => {
532532
tool.addEventListener('click', event => {
533-
const payload = text + ': ' + url;
533+
const payload = encodeURIComponent(text + ': ' + url);
534534
switch (tool.dataset.tool) {
535535
case 'copy': {
536536
navigator.clipboard.writeText(url);
@@ -583,15 +583,15 @@ navigator.share = navigator.share || (function () {
583583
break;
584584
}
585585
case 'linkedin': {
586-
window.open(`https://www.linkedin.com/shareArticle?mini=true&url=${url}&title=${title}&summary=${text}&source=LinkedIn`);
586+
window.open(`https://www.linkedin.com/shareArticle?mini=true&url=${encodeURIComponent(url)}&title=${title}&summary=${text}&source=LinkedIn`);
587587
break;
588588
}
589589
case 'telegram': {
590-
window.open((isDesktop ? 'https://telegram.me/share/msg?url=' + url + '&text=' + encodeURIComponent(text) : 'tg://msg?text=' + payload));
590+
window.open((isDesktop ? 'https://telegram.me/share/msg?url=' + encodeURIComponent(url) + '&text=' + encodeURIComponent(text) : 'tg://msg?text=' + payload));
591591
break;
592592
}
593593
case 'pinterest': {
594-
window.open('https://pinterest.com/pin/create/button/?url=' + url + '&description=' + encodeURIComponent(text) + '&media=' + image);
594+
window.open('https://pinterest.com/pin/create/button/?url=' + encodeURIComponent(url) + '&description=' + encodeURIComponent(text) + '&media=' + image);
595595
break;
596596
}
597597
}

0 commit comments

Comments
 (0)