* @param {import("https").ServerOptions} options server options * @returns {Record } normalized server options
(options)
| 3 | * @returns {Record<string, string | string[] | boolean>} normalized server options |
| 4 | */ |
| 5 | function normalizeOptions(options) { |
| 6 | const normalizedOptions = {}; |
| 7 | |
| 8 | for (const propertyName in options) { |
| 9 | let value = options[propertyName]; |
| 10 | |
| 11 | if (Array.isArray(value)) { |
| 12 | value = value.map((item) => { |
| 13 | if (Buffer.isBuffer(item)) { |
| 14 | return "<Buffer>"; |
| 15 | } else if ( |
| 16 | typeof item.pem !== "undefined" && |
| 17 | Buffer.isBuffer(item.pem) |
| 18 | ) { |
| 19 | item.pem = "<Buffer>"; |
| 20 | } else if ( |
| 21 | typeof item.buf !== "undefined" && |
| 22 | Buffer.isBuffer(item.buf) |
| 23 | ) { |
| 24 | item.buf = "<Buffer>"; |
| 25 | } |
| 26 | |
| 27 | return item; |
| 28 | }); |
| 29 | } else if (Buffer.isBuffer(value)) { |
| 30 | value = "<Buffer>"; |
| 31 | } |
| 32 | |
| 33 | normalizedOptions[propertyName] = value; |
| 34 | } |
| 35 | |
| 36 | return normalizedOptions; |
| 37 | } |
| 38 | |
| 39 | export default normalizeOptions; |
no outgoing calls
no test coverage detected
searching dependent graphs…