(json: { [key: string]: string })
| 424 | } |
| 425 | |
| 426 | export function swapKeysValues(json: { [key: string]: string }) { |
| 427 | const keyValCount = Object.keys(json).length; |
| 428 | const ret: { [key: string]: string } = {}; |
| 429 | for (const key in json) { |
| 430 | ret[json[key]] = key; |
| 431 | } |
| 432 | if (Object.keys(ret).length !== keyValCount) { |
| 433 | console.warn( |
| 434 | `swapKeysValues() failed sanity check: started with ${keyValCount} key-val pairs, ended with ${Object.keys( |
| 435 | ret.length, |
| 436 | )}`, |
| 437 | ); |
| 438 | } |
| 439 | return ret; |
| 440 | } |
| 441 | |
| 442 | const absoluteChecker = new RegExp("^(?:[a-z+]+:)?//", "i"); |
| 443 | export function isUrlRelative(url: string): boolean { |
no outgoing calls
no test coverage detected