/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/url/src/prepend-https.ts
30 строк
644 B
Marco Ciampini
ESLint: Replace strict config with bulk suppressions (#81248)
07 авг 2026, 14:34
Не верифицирован
07 авг 2026, 14:34
7f43eaf
Код
Авторство
О чём код?
import { prependHTTP } from './prepend-http'; /** * Prepends "https://" to a url, if it looks like something that is meant to be a TLD. * * Note: this will not replace "http://" with "https://". * * @param url The URL to test. * * @example * ```js * const actualURL = prependHTTPS( 'wordpress.org' ); // https://wordpress.org * ``` * * @return The updated URL. */ export function prependHTTPS( url: string ): string { if ( ! url ) { return url; } // If url starts with http://, return it as is. if ( url.startsWith( 'http://' ) ) { return url; } url = prependHTTP( url ); return url.replace( /^http:/, 'https:' ); }