Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 1x 483x 50x 1x 48x 3x 45x 45x 45x 45x 45x 45x 45x | export function removeUndefinedFromObj(obj: Record<string, unknown>) { Object.keys(obj).forEach(key => obj[key] === undefined ? delete obj[key] : {}); return obj; } interface ParsedApiKey { key: string; name: string; isTesting: boolean; } export const parseApiKey = (inKey: string): ParsedApiKey => { // check the LIVE- / test- prefix if (!/^LIVE\-|test\-/.test(inKey)) { throw new Error("bad key format"); } // chop off the LIVE- / test- prefix const key = inKey.substring(5); const matcher = /[a-f0-9]{8}\-[a-f0-9]{4}\-[a-f0-9]{4}\-[a-f0-9]{4}\-[a-f0-9]{12}$/; const results = key.match(matcher); Iif (!results) { throw new Error("bad key format"); } Iif (!results.index) { throw new Error("bad key format"); } const retval = { key: key.slice(results.index), name: key.slice(0, results.index - 1), isTesting: inKey.indexOf("LIVE-") === -1, }; return retval; }; |