mailto-sanitizer

1.0.0 • Public • Published

Build Status

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:name@domain.cz">name@domain.cz</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:name@domain.cz">name@domain.cz</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()));
});

Readme

Keywords

Package Sidebar

Install

npm i mailto-sanitizer

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • winsik