Socket
Socket
Sign inDemoInstall

envfile

Package Overview
Dependencies
0
Maintainers
1
Versions
103
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.1.0-next.1703892181.6abd59fa202a0d1cac58adaf6ad430a4dd0d84bd to 7.1.0-next.1709117147.dc6083d00c810cc6c64bba3a3e9ba728796b6976

23

edition-browsers/index.js

@@ -5,5 +5,5 @@ // perhaps in the future we can use @bevry/json's toJSON and parseJSON and JSON.stringify to support more advanced types

const result = {};
const lines = src.toString().split('\n');
const lines = splitInLines(src);
for (const line of lines) {
const match = line.match(/^([^=:#]+?)[=:](.*)/);
const match = line.match(/^([^=:#]+?)[=:]((.|\n)*)/);
if (match) {

@@ -22,3 +22,3 @@ const key = match[1].trim();

if (key) {
const line = `${key}=${String(value)}`;
const line = `${key}=${jsonValueToEnv(value)}`;
result += line + '\n';

@@ -29,1 +29,18 @@ }

}
function splitInLines(src) {
return src
.replace(/("[\s\S]*?")/g, (_m, cg) => {
return cg.replace(/\n/g, '%%LINE-BREAK%%');
})
.split('\n')
.filter((i) => Boolean(i.trim()))
.map((i) => i.replace(/%%LINE-BREAK%%/g, '\n'));
}
function jsonValueToEnv(value) {
let processedValue = String(value);
processedValue = processedValue.replace(/\n/g, '\\n');
processedValue = processedValue.includes('\\n')
? `"${processedValue}"`
: processedValue;
return processedValue;
}

@@ -12,5 +12,5 @@ /** We don't normalize anything, so it is just strings and strings. */

const result: Data = {}
const lines = src.toString().split('\n')
const lines = splitInLines(src)
for (const line of lines) {
const match = line.match(/^([^=:#]+?)[=:](.*)/)
const match = line.match(/^([^=:#]+?)[=:]((.|\n)*)/)
if (match) {

@@ -30,3 +30,3 @@ const key = match[1].trim()

if (key) {
const line = `${key}=${String(value)}`
const line = `${key}=${jsonValueToEnv(value)}`
result += line + '\n'

@@ -37,1 +37,20 @@ }

}
function splitInLines(src: string): string[] {
return src
.replace(/("[\s\S]*?")/g, (_m, cg) => {
return cg.replace(/\n/g, '%%LINE-BREAK%%')
})
.split('\n')
.filter((i) => Boolean(i.trim()))
.map((i) => i.replace(/%%LINE-BREAK%%/g, '\n'))
}
function jsonValueToEnv(value: any): string {
let processedValue = String(value)
processedValue = processedValue.replace(/\n/g, '\\n')
processedValue = processedValue.includes('\\n')
? `"${processedValue}"`
: processedValue
return processedValue
}

@@ -5,5 +5,5 @@ // perhaps in the future we can use @bevry/json's toJSON and parseJSON and JSON.stringify to support more advanced types

const result = {};
const lines = src.toString().split('\n');
const lines = splitInLines(src);
for (const line of lines) {
const match = line.match(/^([^=:#]+?)[=:](.*)/);
const match = line.match(/^([^=:#]+?)[=:]((.|\n)*)/);
if (match) {

@@ -22,3 +22,3 @@ const key = match[1].trim();

if (key) {
const line = `${key}=${String(value)}`;
const line = `${key}=${jsonValueToEnv(value)}`;
result += line + '\n';

@@ -29,1 +29,18 @@ }

}
function splitInLines(src) {
return src
.replace(/("[\s\S]*?")/g, (_m, cg) => {
return cg.replace(/\n/g, '%%LINE-BREAK%%');
})
.split('\n')
.filter((i) => Boolean(i.trim()))
.map((i) => i.replace(/%%LINE-BREAK%%/g, '\n'));
}
function jsonValueToEnv(value) {
let processedValue = String(value);
processedValue = processedValue.replace(/\n/g, '\\n');
processedValue = processedValue.includes('\\n')
? `"${processedValue}"`
: processedValue;
return processedValue;
}

@@ -8,5 +8,5 @@ "use strict";

const result = {};
const lines = src.toString().split('\n');
const lines = splitInLines(src);
for (const line of lines) {
const match = line.match(/^([^=:#]+?)[=:](.*)/);
const match = line.match(/^([^=:#]+?)[=:]((.|\n)*)/);
if (match) {

@@ -26,3 +26,3 @@ const key = match[1].trim();

if (key) {
const line = `${key}=${String(value)}`;
const line = `${key}=${jsonValueToEnv(value)}`;
result += line + '\n';

@@ -34,1 +34,18 @@ }

exports.stringify = stringify;
function splitInLines(src) {
return src
.replace(/("[\s\S]*?")/g, (_m, cg) => {
return cg.replace(/\n/g, '%%LINE-BREAK%%');
})
.split('\n')
.filter((i) => Boolean(i.trim()))
.map((i) => i.replace(/%%LINE-BREAK%%/g, '\n'));
}
function jsonValueToEnv(value) {
let processedValue = String(value);
processedValue = processedValue.replace(/\n/g, '\\n');
processedValue = processedValue.includes('\\n')
? `"${processedValue}"`
: processedValue;
return processedValue;
}

2

package.json
{
"name": "envfile",
"version": "7.1.0-next.1703892181.6abd59fa202a0d1cac58adaf6ad430a4dd0d84bd",
"version": "7.1.0-next.1709117147.dc6083d00c810cc6c64bba3a3e9ba728796b6976",
"license": "Artistic-2.0",

@@ -5,0 +5,0 @@ "description": "Parse and stringify the environment configuration files and format, also known as .env files and dotenv files",

@@ -12,5 +12,5 @@ /** We don't normalize anything, so it is just strings and strings. */

const result: Data = {}
const lines = src.toString().split('\n')
const lines = splitInLines(src)
for (const line of lines) {
const match = line.match(/^([^=:#]+?)[=:](.*)/)
const match = line.match(/^([^=:#]+?)[=:]((.|\n)*)/)
if (match) {

@@ -30,3 +30,3 @@ const key = match[1].trim()

if (key) {
const line = `${key}=${String(value)}`
const line = `${key}=${jsonValueToEnv(value)}`
result += line + '\n'

@@ -37,1 +37,20 @@ }

}
function splitInLines(src: string): string[] {
return src
.replace(/("[\s\S]*?")/g, (_m, cg) => {
return cg.replace(/\n/g, '%%LINE-BREAK%%')
})
.split('\n')
.filter((i) => Boolean(i.trim()))
.map((i) => i.replace(/%%LINE-BREAK%%/g, '\n'))
}
function jsonValueToEnv(value: any): string {
let processedValue = String(value)
processedValue = processedValue.replace(/\n/g, '\\n')
processedValue = processedValue.includes('\\n')
? `"${processedValue}"`
: processedValue
return processedValue
}
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