New line parse in environment variables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// set the TEST environment variable with TEST=first line\\n\\nsecond line\\n | |
// you need to duplicate the \ to scape it | |
function parseEnvVarible(envVar){ | |
return new Buffer(envVar.split('\\n').join(require('os').EOL), 'UTF-8').toString('UTF-8'); | |
} | |
console.log('Wrong: ' + process.env.TEST); | |
console.log('Right: ' + parseEnvVarible(process.env.TEST)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment