(src)
| 39 | |
| 40 | // Parse src into an Object |
| 41 | function parse (src) { |
| 42 | const obj = {} |
| 43 | |
| 44 | // Convert buffer to string |
| 45 | let lines = src.toString() |
| 46 | |
| 47 | // Convert line breaks to same format |
| 48 | lines = lines.replace(/\r\n?/mg, '\n') |
| 49 | |
| 50 | let match |
| 51 | while ((match = LINE.exec(lines)) != null) { |
| 52 | const key = match[1] |
| 53 | |
| 54 | // Default undefined or null to empty string |
| 55 | let value = (match[2] || '') |
| 56 | |
| 57 | // Remove whitespace |
| 58 | value = value.trim() |
| 59 | |
| 60 | // Check if double quoted |
| 61 | const maybeQuote = value[0] |
| 62 | |
| 63 | // Remove surrounding quotes |
| 64 | value = value.replace(/^(['"`])([\s\S]*)\1$/mg, '$2') |
| 65 | |
| 66 | // Expand newlines if double quoted |
| 67 | if (maybeQuote === '"') { |
| 68 | value = value.replace(/\\n/g, '\n') |
| 69 | value = value.replace(/\\r/g, '\r') |
| 70 | } |
| 71 | |
| 72 | // Add to object |
| 73 | obj[key] = value |
| 74 | } |
| 75 | |
| 76 | return obj |
| 77 | } |
| 78 | |
| 79 | function _parseVault (options) { |
| 80 | options = options || {} |
no outgoing calls
no test coverage detected
searching dependent graphs…