Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

munge

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

munge - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

src/index.js

2

dist/munge.js

@@ -1,2 +0,2 @@

var n={TYPES:["ascii","utf8","random"],DEFAULT:"random",ascii:function(n){return n&&n.charCodeAt()},utf8:function(n){for(var i=this.ascii(n).toString(16).toUpperCase();i.length<4;)i="0"+i;return"x"+i},random:function(n){return this[this.TYPES[Math.floor(Math.random()*this.TYPES.length)]](n)}};module.exports=function(i,o){var r,t,e=[];if((o=o||{}).encoding){if(n.TYPES.indexOf(o.encoding)<0)throw Error("Invalid encoding option given: "+o.encoding)}else o.encoding=n.DEFAULT;if(i)for(t in r=i.split(""))e[t]="&#"+n[o.encoding](r[t])+";";return e.join("")};
var n={TYPES:["ascii","utf8","random"],DEFAULT:"random",ascii:{alreadyMunged:function(n){if(n.startsWith("&#"))return n},munge:function(n){return n&&n.charCodeAt()}},utf8:{alreadyMunged:function(n){if(n.startsWith("&#x"))return n},munge:function(r){for(var e=n.ascii.munge(r).toString(16).toUpperCase();e.length<4;)e="0"+e;return"x"+e}},random:{alreadyMunged:function(r){return n.ascii.alreadyMunged(r)||n.utf8.alreadyMunged(r)},munge:function(r){var e=n.TYPES[Math.floor(Math.random()*n.TYPES.length)];return n[e].munge(r)}}};module.exports=function(r,e){var i,t,a=[];if((e=e||{}).encoding){if(n.TYPES.indexOf(e.encoding)<0)throw Error("Invalid encoding option given: "+e.encoding)}else e.encoding=n.DEFAULT;var o=n[e.encoding];if(r){if(o.alreadyMunged(r))return r;for(t in i=r.split(""))a[t]="&#"+o.munge(i[t])+";"}return a.join("")};
//# sourceMappingURL=munge.js.map

@@ -1,2 +0,2 @@

const n={TYPES:["ascii","utf8","random"],DEFAULT:"random",ascii:function(n){return n&&n.charCodeAt()},utf8:function(n){for(var i=this.ascii(n).toString(16).toUpperCase();i.length<4;)i="0"+i;return"x"+i},random:function(n){return this[this.TYPES[Math.floor(Math.random()*this.TYPES.length)]](n)}};module.exports=function(i,o){const t=[];var r,e;if((o=o||{}).encoding){if(n.TYPES.indexOf(o.encoding)<0)throw Error("Invalid encoding option given: "+o.encoding)}else o.encoding=n.DEFAULT;if(i)for(e in r=i.split(""))t[e]="&#"+n[o.encoding](r[e])+";";return t.join("")};
const n={TYPES:["ascii","utf8","random"],DEFAULT:"random",ascii:{alreadyMunged:function(n){if(n.startsWith("&#"))return n},munge:function(n){return n&&n.charCodeAt()}},utf8:{alreadyMunged:function(n){if(n.startsWith("&#x"))return n},munge:function(e){for(var r=n.ascii.munge(e).toString(16).toUpperCase();r.length<4;)r="0"+r;return"x"+r}},random:{alreadyMunged:function(e){return n.ascii.alreadyMunged(e)||n.utf8.alreadyMunged(e)},munge:function(e){const r=n.TYPES[Math.floor(Math.random()*n.TYPES.length)];return n[r].munge(e)}}};module.exports=function(e,r){const t=[];var i,o;if((r=r||{}).encoding){if(n.TYPES.indexOf(r.encoding)<0)throw Error("Invalid encoding option given: "+r.encoding)}else r.encoding=n.DEFAULT;const u=n[r.encoding];if(e){if(u.alreadyMunged(e))return e;for(o in i=e.split(""))t[o]="&#"+u.munge(i[o])+";"}return t.join("")};
//# sourceMappingURL=munge.modern.js.map

@@ -1,2 +0,2 @@

!function(n){"function"==typeof define&&define.amd?define(n):n()}(function(){var n={TYPES:["ascii","utf8","random"],DEFAULT:"random",ascii:function(n){return n&&n.charCodeAt()},utf8:function(n){for(var i=this.ascii(n).toString(16).toUpperCase();i.length<4;)i="0"+i;return"x"+i},random:function(n){return this[this.TYPES[Math.floor(Math.random()*this.TYPES.length)]](n)}};module.exports=function(i,o){var t,e,r=[];if((o=o||{}).encoding){if(n.TYPES.indexOf(o.encoding)<0)throw Error("Invalid encoding option given: "+o.encoding)}else o.encoding=n.DEFAULT;if(i)for(e in t=i.split(""))r[e]="&#"+n[o.encoding](t[e])+";";return r.join("")}});
!function(n){"function"==typeof define&&define.amd?define(n):n()}(function(){var n={TYPES:["ascii","utf8","random"],DEFAULT:"random",ascii:{alreadyMunged:function(n){if(n.startsWith("&#"))return n},munge:function(n){return n&&n.charCodeAt()}},utf8:{alreadyMunged:function(n){if(n.startsWith("&#x"))return n},munge:function(e){for(var r=n.ascii.munge(e).toString(16).toUpperCase();r.length<4;)r="0"+r;return"x"+r}},random:{alreadyMunged:function(e){return n.ascii.alreadyMunged(e)||n.utf8.alreadyMunged(e)},munge:function(e){var r=n.TYPES[Math.floor(Math.random()*n.TYPES.length)];return n[r].munge(e)}}};module.exports=function(e,r){var i,t,o=[];if((r=r||{}).encoding){if(n.TYPES.indexOf(r.encoding)<0)throw Error("Invalid encoding option given: "+r.encoding)}else r.encoding=n.DEFAULT;var u=n[r.encoding];if(e){if(u.alreadyMunged(e))return e;for(t in i=e.split(""))o[t]="&#"+u.munge(i[t])+";"}return o.join("")}});
//# sourceMappingURL=munge.umd.js.map
{
"name": "munge",
"version": "1.0.0",
"version": "1.1.0",
"description": "a tiny node module to munge any strings. useful if you want to obfuscate email addresses to valid, numeric html entities.",

@@ -10,3 +10,3 @@ "author": {

},
"source": "index.js",
"source": "src/index.js",
"main": "dist/munge.js",

@@ -21,10 +21,8 @@ "module": "dist/munge.mjs",

"devDependencies": {
"microbundle": "0.12.4",
"microbundle": "0.13.3",
"nodeunit": "0.11.3",
"standard": "14.3.4"
"standard": "16.0.3"
},
"engines": {
"node": ">=8.10.0",
"yarn": ">=1.3.0",
"npm": ">=5.4.0"
"node": ">=12.10.0"
},

@@ -31,0 +29,0 @@ "keywords": [

@@ -5,3 +5,3 @@ # munge

ummm, just a tiny node module to munge any strings. useful if wou want to obfuscate email addresses to valid, numeric html characters.
a tiny library to munge any strings (do not ask me why that verb). useful if wou want to obfuscate email addresses to valid, numeric html characters.

@@ -57,3 +57,3 @@ as long as spam robots are still dumb, this should significantly reduce the risk of the email address being harvested. i bet you get 60% less spam. this method is user friendlier and way easier to implement than other tricks like javascript or images. because you really can click on the link and it opens in your mail program.

### jade integration
### jade/express integration

@@ -60,0 +60,0 @@ good idea. you will want to protect your email address on your contact page.

@@ -15,3 +15,3 @@ const testCase = require('nodeunit').testCase

'loading munge (require)': function (t) {
munge = require('../index.js')
munge = require('../src/index.js')

@@ -71,3 +71,3 @@ t.ok(munge, 'munge module is loaded.')

t.ok(mungedEmailAddress, 'ascii mungedd email address is not empty.')
t.ok(mungedEmailAddress, 'ascii munged email address is not empty.')
t.ok(isString(mungedEmailAddress), 'ascii munged email address is a string.')

@@ -90,3 +90,29 @@ t.strictEqual(mungedEmailAddress, MUNGED_EMAIL_ADDRESS, 'ascii munged email address is correct.')

t.done()
}
},
'do not munge already munged ascii address': function (t) {
const MUNGED_EMAIL_ADDRESS = '&#115;&#112;&#97;&#99;&#101;&#109;&#111;&#110;&#107;&#101;&#121;&#64;&#109;&#111;&#111;&#110;&#46;&#99;&#111;&#109;'
const EMAIL_ADDRESS = MUNGED_EMAIL_ADDRESS
const mungedEmailAddress = munge(EMAIL_ADDRESS, { encoding: 'ascii' })
t.ok(mungedEmailAddress, 'ascii munged 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()
},
'do not munge already munged UTF8 email address': function (t) {
const MUNGED_EMAIL_ADDRESS = '&#x0073;&#x0070;&#x0061;&#x0063;&#x0065;&#x006D;&#x006F;&#x006E;&#x006B;&#x0065;&#x0079;&#x0040;&#x006D;&#x006F;&#x006F;&#x006E;&#x002E;&#x0063;&#x006F;&#x006D;'
const EMAIL_ADDRESS = MUNGED_EMAIL_ADDRESS
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.done()
},
})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc