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

firebase-encode

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

firebase-encode - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

29

lib/index.js

@@ -6,11 +6,32 @@ 'use strict';

});
// http://stackoverflow.com/a/6969486/692528
var escapeRegExp = function escapeRegExp(str) {
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
};
// http://stackoverflow.com/a/19148116/692528
var dots = /\./g;
var escapedDot = '%2E';
var chars = '.$[]#/%'.split('');
var charCodes = chars.map(function (c) {
return '%' + c.charCodeAt(0).toString(16).toUpperCase();
});
var charToCode = {};
var codeToChar = {};
chars.forEach(function (c, i) {
charToCode[c] = charCodes[i];
codeToChar[charCodes[i]] = c;
});
var charsRegex = new RegExp('[' + escapeRegExp(chars.join('')) + ']', 'g');
var charCodesRegex = new RegExp(charCodes.join('|'), 'g');
var encode = function encode(str) {
return encodeURIComponent(str).replace(dots, escapedDot);
return str.replace(charsRegex, function (match) {
return charToCode[match];
});
};
var decode = function decode(str) {
return decodeURIComponent(str.replace(escapedDot, '.'));
return str.replace(charCodesRegex, function (match) {
return codeToChar[match];
});
};

@@ -17,0 +38,0 @@

2

package.json
{
"name": "firebase-encode",
"version": "0.0.2",
"version": "0.0.3",
"description": "Encode (escape) and decode firebase key string to avoid unexpected results.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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