/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/url/src/is-valid-protocol.ts
19 строк
463 B
Eshaan Dabasiya
Migrate `@packages/url` package to TypeScript (#70496)
18 июл 2025, 13:25
Не верифицирован
18 июл 2025, 13:25
443d8fa
Код
Авторство
О чём код?
/** * Tests if a url protocol is valid. * * @param protocol The url protocol. * * @example * ```js * const isValid = isValidProtocol( 'https:' ); // true * const isNotValid = isValidProtocol( 'https :' ); // false * ``` * * @return True if the argument is a valid protocol (e.g. http:, tel:). */ export function isValidProtocol( protocol: string ): boolean { if ( ! protocol ) { return false; } return /^[a-z\-.\+]+[0-9]*:$/i.test( protocol ); }