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 35 36 37 38 39 40 41 42 43 44 45 46 47 | 33x 33x 36x 36x 36x 36x 33x 36x 33x 36x 36x | import { BeeArgumentError } from './error' /** * Validates that passed string is valid URL of Bee. * We support only HTTP and HTTPS protocols. * * @param url */ export function isValidBeeUrl(url: unknown): url is URL { try { Iif (typeof url !== 'string') { return false } const urlObject = new URL(url) // There can be wide range of protocols passed. return urlObject.protocol === 'http:' || urlObject.protocol === 'https:' } catch (e) { return false } } /** * Validates that passed string is valid URL of Bee, if not it throws BeeArgumentError. * We support only HTTP and HTTPS protocols. * @param url * @throws BeeArgumentError if non valid URL */ export function assertBeeUrl(url: unknown): asserts url is URL { Iif (!isValidBeeUrl(url)) { throw new BeeArgumentError('URL is not valid!', url) } } /** * Removes trailing slash out of the given string. * @param url */ export function stripLastSlash(url: string): string { Iif (url.endsWith('/')) { return url.slice(0, -1) } return url } |