UNPKG

ts-caddyfile

Version:
26 lines (25 loc) 977 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const BasicAuthCoreExtract = /(?!.*basicauth)\s((.|\n)*)(?<!\})/; const OtherBasicAuthExtract = /\s+?"?(?<username>.*(?<!")).*\s(?<password>\w+)\s\{((.|\n)*)realm\s"?(?<realm>.*(?<!")).*/gm; function processBasicAuthDirective(directive) { const core = BasicAuthCoreExtract.exec(directive)[0]; // if (core.match(/\n/).length) if (!core.match('\n')) return { type: 'basicauth', .../(?!.*basicauth)\s(?<path>.*)\s(?<username>\S+)\s(?<password>\S+)/.exec(directive) .groups }; return { type: 'basicauth', ...OtherBasicAuthExtract.exec(core).groups, files: core .replace(OtherBasicAuthExtract, '') .replace(/\s+/, '') .replace(/\t/, '') .split(/\n/) .filter(a => a.length > 0) }; } exports.processBasicAuthDirective = processBasicAuthDirective;