Link: Use HTTPS as default prefix (#3736)

This commit is contained in:
Alexander Zinchuk 2023-08-14 11:17:59 +02:00
parent c7db27482d
commit 493e62b5c2
2 changed files with 2 additions and 4 deletions

View File

@ -1,7 +1,5 @@
const PROTOCOL_WHITELIST = new Set(['http:', 'https:', 'tg:', 'ton:', 'mailto:', 'tel:']);
// HTTP was chosen by default as a fix for https://bugs.telegram.org/c/10712.
// It is also the default protocol in the official TDesktop client.
const FALLBACK_PREFIX = 'http://';
const FALLBACK_PREFIX = 'https://';
export function ensureProtocol(url?: string) {
if (!url) {

View File

@ -135,7 +135,7 @@ function parseMarkdown(html: string) {
function parseMarkdownLinks(html: string) {
return html.replace(new RegExp(`\\[([^\\]]+?)]\\((${RE_LINK_TEMPLATE}+?)\\)`, 'g'), (_, text, link) => {
const url = link.includes('://') ? link : link.includes('@') ? `mailto:${link}` : `http://${link}`;
const url = link.includes('://') ? link : link.includes('@') ? `mailto:${link}` : `https://${link}`;
return `<a href="${url}">${text}</a>`;
});
}