Socket
Socket
Sign inDemoInstall

munge

Package Overview
Dependencies
0
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.8 to 0.2.0

dist/munge.js

60

package.json
{
"name": "munge",
"version": "0.1.8",
"description": "a tiny node module to munge any strings. useful if you want to obfuscate email addresses to valid, numeric html entities.",
"main": "munge.js",
"author": "Michael Heuberger <michael.heuberger@binarykitchen.com>",
"keywords": ["munge", "email", "spam", "obfuscation", "ascii", "utf8"],
"devDependencies": {
"nodeunit": "0.11.0"
},
"engines": {
"node": ">=4.2.0"
},
"scripts": {
"test": "nodeunit tests/basics.js"
},
"repository": {
"type": "git",
"url": "https://github.com/binarykitchen/munge.git"
},
"license": "MIT"
"name": "munge",
"version": "0.2.0",
"description": "a tiny node module to munge any strings. useful if you want to obfuscate email addresses to valid, numeric html entities.",
"author": {
"name": "Michael Heuberger",
"email": "michael.heuberger@binarykitchen.com",
"url": "https://binarykitchen.com"
},
"source": "index.js",
"main": "dist/munge.js",
"module": "dist/munge.mjs",
"unpkg": "dist/munge.umd.js",
"scripts": {
"test": "nodeunit tests/basics.js",
"lint": "standard index.js",
"build": "microbundle"
},
"devDependencies": {
"microbundle": "0.11.0",
"nodeunit": "0.11.3",
"standard": "13.1.0"
},
"engines": {
"node": ">=8.10.0",
"yarn": ">=1.3.0",
"npm": ">=5.4.0"
},
"keywords": [
"munge",
"email",
"spam",
"obfuscation",
"ascii",
"utf8"
],
"repository": {
"type": "git",
"url": "git@github.com:binarykitchen/munge.git"
},
"license": "MIT"
}

@@ -1,94 +0,89 @@

"use strict";
const testCase = require('nodeunit').testCase
var testCase = require('nodeunit').testCase,
munge;
var munge
// boo, type checks are not enabled in nodeunit
function isFunction(anything)
{
return typeof(anything) == 'function';
function isFunction (anything) {
return typeof (anything) === 'function'
}
// boo, type checks are not enabled in nodeunit
function isString(anything)
{
return typeof(anything) == 'string';
function isString (anything) {
return typeof (anything) === 'string'
}
module.exports = testCase({
'loading munge (require)': function(t) {
munge = require('../munge.js');
'loading munge (require)': function (t) {
munge = require('../index.js')
t.ok(munge, 'munge module is loaded.');
t.done()
},
t.ok(munge, 'munge module is loaded.')
t.done()
},
'checking type munge.email': function(t) {
t.ok(isFunction(munge), 'type of munge.email is a function.');
t.done();
},
'checking type munge.email': function (t) {
t.ok(isFunction(munge), 'type of munge.email is a function.')
t.done()
},
'munge with weird parameters': function(t) {
var nothingMunged = munge();
t.strictEqual(nothingMunged, '', 'empty parameter returns an empty string');
'munge with weird parameters': function (t) {
const nothingMunged = munge()
t.strictEqual(nothingMunged, '', 'empty parameter returns an empty string')
t.throws(function() {
munge({});
}, 'TypeError', 'first parameter as an object causes TypeError to be thrown.');
t.throws(function () {
munge({})
}, 'TypeError', 'first parameter as an object causes TypeError to be thrown.')
t.throws(function() {
munge(null, {encoding: 'hex'});
}, 'Error', 'unsupported encoding parameter causes an error to be thrown.');
t.throws(function () {
munge(null, { encoding: 'hex' })
}, 'Error', 'unsupported encoding parameter causes an error to be thrown.')
t.doesNotThrow(function() {
munge(null, {encoding: 'ascii'});
}, 'Error', 'encoding option ascii should not throw an error.');
t.doesNotThrow(function () {
munge(null, { encoding: 'ascii' })
}, 'Error', 'encoding option ascii should not throw an error.')
t.doesNotThrow(function() {
munge(null, {encoding: 'utf8'});
}, 'Error', 'encoding option utf8 should not throw an error.');
t.doesNotThrow(function () {
munge(null, { encoding: 'utf8' })
}, 'Error', 'encoding option utf8 should not throw an error.')
t.doesNotThrow(function() {
munge(null, {encoding: 'random'});
}, 'Error', 'encoding option random should not throw an error.');
t.doesNotThrow(function () {
munge(null, { encoding: 'random' })
}, 'Error', 'encoding option random should not throw an error.')
t.done();
},
t.done()
},
'munge my own email address by random': function(t) {
var EMAIL_ADDRESS = 'spacemonkey@moon.com';
'munge my own email address by random': function (t) {
const EMAIL_ADDRESS = 'spacemonkey@moon.com'
var mungedEmailAddress = munge(EMAIL_ADDRESS);
const mungedEmailAddress = munge(EMAIL_ADDRESS)
t.ok(mungedEmailAddress, 'munged email address is not empty.');
t.ok(isString(mungedEmailAddress), 'munged email address is a string.');
t.ok(mungedEmailAddress, 'munged email address is not empty.')
t.ok(isString(mungedEmailAddress), 'munged email address is a string.')
t.done();
},
t.done()
},
'ASCII munge my own email address': function(t) {
var EMAIL_ADDRESS = 'spacemonkey@moon.com',
MUNGED_EMAIL_ADDRESS = '&#115;&#112;&#97;&#99;&#101;&#109;&#111;&#110;&#107;&#101;&#121;&#64;&#109;&#111;&#111;&#110;&#46;&#99;&#111;&#109;';
'ASCII munge my own email address': function (t) {
const EMAIL_ADDRESS = 'spacemonkey@moon.com'
const MUNGED_EMAIL_ADDRESS = '&#115;&#112;&#97;&#99;&#101;&#109;&#111;&#110;&#107;&#101;&#121;&#64;&#109;&#111;&#111;&#110;&#46;&#99;&#111;&#109;'
var mungedEmailAddress = munge(EMAIL_ADDRESS, {encoding: 'ascii'});
const mungedEmailAddress = munge(EMAIL_ADDRESS, { encoding: 'ascii' })
t.ok(mungedEmailAddress, 'ascii mungedd email address is not empty.');
t.ok(isString(mungedEmailAddress), 'ascii munged email address is a string.');
t.strictEqual(mungedEmailAddress, MUNGED_EMAIL_ADDRESS, 'ascii munged email address is correct.');
t.ok(mungedEmailAddress, 'ascii mungedd email address is not empty.')
t.ok(isString(mungedEmailAddress), 'ascii munged email address is a string.')
t.strictEqual(mungedEmailAddress, MUNGED_EMAIL_ADDRESS, 'ascii munged email address is correct.')
t.done();
},
t.done()
},
'UTF8 munge my own email address': function(t) {
var EMAIL_ADDRESS = 'spacemonkey@moon.com',
MUNGED_EMAIL_ADDRESS = '&#x0073;&#x0070;&#x0061;&#x0063;&#x0065;&#x006D;&#x006F;&#x006E;&#x006B;&#x0065;&#x0079;&#x0040;&#x006D;&#x006F;&#x006F;&#x006E;&#x002E;&#x0063;&#x006F;&#x006D;';
'UTF8 munge my own email address': function (t) {
const EMAIL_ADDRESS = 'spacemonkey@moon.com'
const MUNGED_EMAIL_ADDRESS = '&#x0073;&#x0070;&#x0061;&#x0063;&#x0065;&#x006D;&#x006F;&#x006E;&#x006B;&#x0065;&#x0079;&#x0040;&#x006D;&#x006F;&#x006F;&#x006E;&#x002E;&#x0063;&#x006F;&#x006D;'
var mungedEmailAddress = munge(EMAIL_ADDRESS, {encoding: 'utf8'});
const mungedEmailAddress = munge(EMAIL_ADDRESS, { encoding: 'utf8' })
t.ok(mungedEmailAddress, 'utf8 munged email address is not empty.');
t.ok(isString(mungedEmailAddress), 'utf8 munged email address is a string.');
t.strictEqual(mungedEmailAddress, MUNGED_EMAIL_ADDRESS, 'utf8 munged email address is correct.');
t.ok(mungedEmailAddress, 'utf8 munged email address is not empty.')
t.ok(isString(mungedEmailAddress), 'utf8 munged email address is a string.')
t.strictEqual(mungedEmailAddress, MUNGED_EMAIL_ADDRESS, 'utf8 munged email address is correct.')
t.done();
}
});
t.done()
}
})

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc