mailto-sanitizer
v1.0.0
Published
Transform sanitized mail email(at)domain(to)org into mailto element
Downloads
1
Readme
MailtoSanitizer
Simple utility for transformation sanitized email in mailto element.
Instalation
Bower
bower install mailto-sanitizer
Npm
npm install mailto-sanitizer
Usage
Default behavior
replaceMethod replaces string a (at) and (dot) are replaced with @ and .
var sanitizer = new MailtoSanitizer();
var mailto = sanitizer.replace('name(at)domain(dot).cz');
console.log(mailto); // <a href="mailto:[email protected]">[email protected]</a>
Configurable replacements
At and dot replacements can be configured with constructor parameters.
var sanitizer = new MailtoSanitizer('zavináč', 'tečka');
var mailto = sanitizer.replace('name(zavináč)domain(tečka).cz');
console.log(mailto); // <a href="mailto:[email protected]">[email protected]</a>
Example with element replacement
<span class="email-replace">angular(zavináč)angular(tečka)cz</span>
var sanitizer = new MailtoSanitizer("zavináč", "tečka");
var text = $('.email-replace').each(function() {
$(this).html(sanitizer.replace($(this).html()));
});