Skip to content

Instantly share code, notes, and snippets.

if(Meteor.isServer) {
cheerio = Npm.require("cheerio");
}
validEmail = function (email) {
var re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
};
purify = function(text, allowedTags, allowedAttributes) {
@dstollie
dstollie / purify_common.js
Created March 27, 2015 10:40
Simple purify method for meteor which uses cristo-rabani's package: https://github.com/cristo-rabani/meteor-universe-html-purifier
purify = function(text, allowedTags, allowedAttributes) {
if(!allowedTags) allowedTags = ['b', 'i', 'strong', 'em', 'ol', 'ul', 'li', 'p', 'span', 'a', 'img', 'br'];
if(!allowedAttributes) allowedAttributes = ['href', 'src'];
var disallowedTags = ['b', 'i', 'strong', 'em', 'blockquote', 'ol', 'ul', 'li', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'h7', 'p', 'span', 'pre', 'a', 'u', 'img', 'br', 'table'];
// Check the difference between the default enabled tags and the allowed tags
var disallowedTags = _.difference(disallowedTags, allowedTags);