Created
February 5, 2015 02:49
-
-
Save webjay/66ec31e2264c62e701ac to your computer and use it in GitHub Desktop.
quoted-printable form part
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
'use strict'; | |
var mimelib = require('mimelib'); | |
var EOL = '\r\n'; | |
module.exports = formpart; | |
function escapeQuotation (str) { | |
return str.replace(/"/g, '\"'); | |
} | |
function formpart (boundary, name, value) { | |
var lines = [ | |
'Content-Disposition: form-data; name="' + escapeQuotation(name) + '"', | |
'Content-Type: text/plain; charset=UTF-8', | |
'Content-Transfer-Encoding: quoted-printable' | |
]; | |
var part = ''; | |
part += '--' + boundary + EOL; | |
lines.forEach(function (line) { | |
part += mimelib.foldLine(line); | |
part += EOL; | |
}); | |
part += EOL; | |
part += mimelib.encodeQuotedPrintable(value); | |
part += EOL; | |
return part; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment