mirror of
https://github.com/nunocoracao/blowfish.git
synced 2026-11-09 20:49:20 +00:00
fix: auto detect mailto prefix
This commit is contained in:
1 file changed
+4
-3
+4
-3
@@ -1,11 +1,12 @@
|
|||||||
(function () {
|
(function () {
|
||||||
const links = document.querySelectorAll(".email-link");
|
const links = document.querySelectorAll(".email-link");
|
||||||
links.forEach((link) => {
|
links.forEach((link) => {
|
||||||
const email = atob(link.getAttribute("data-email"));
|
let email = atob(link.getAttribute("data-email"));
|
||||||
const subject = link.getAttribute("data-subject");
|
const subject = link.getAttribute("data-subject");
|
||||||
let mailto = "mailto:" + email;
|
let mailto = email.startsWith("mailto:") ? email : "mailto:" + email;
|
||||||
|
|
||||||
if (subject) {
|
if (subject) {
|
||||||
mailto += "?subject=" + encodeURIComponent(subject);
|
mailto += (mailto.includes("?") ? "&" : "?") + "subject=" + encodeURIComponent(subject);
|
||||||
}
|
}
|
||||||
link.href = mailto;
|
link.href = mailto;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user