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 | 2x 2x 2x 2x 190x 2x 190x 8x | import { SUPPORTED_PROTOCOLS } from './const' import { InvalidProtocolError } from './errors' import { stripEnd } from './utils' import { Protocol } from './types' /** * Checks if the given protocol is supported. * Note: The validated protocol should include the colon (:) at the end. * * @param {string} protocol - The protocol to be checked for support. * @return {boolean} Returns true if the protocol is supported, otherwise false. */ export function isSupportedProtocol(protocol: string): protocol is Protocol { return (SUPPORTED_PROTOCOLS as string[]).includes(protocol) } /** * Validates whether the specified protocol is supported. * Throws an error if the protocol is invalid. * * @param {string} protocol - The protocol to validate. */ export function validateProtocol(protocol: string): asserts protocol is Protocol { if (!isSupportedProtocol(protocol)) { throw new InvalidProtocolError(stripEnd(protocol)) } } |