[FIX] - Links do not work if protocol is not set in URL prefix

This commit is contained in:
gitstart 2022-10-25 07:13:52 +00:00
commit a65655beb7
1 changed files with 8 additions and 1 deletions

View File

@ -36,10 +36,17 @@ const appSchemeURL = (url: string, browser: string): string => {
return schemeUrl; return schemeUrl;
}; };
const addProtocol = (url: string): string => {
if (!url.toLowerCase().startsWith('http')) {
return `https://${url}`;
}
return url;
};
const openLink = async (url: string, theme: TSupportedThemes = 'light'): Promise<void> => { const openLink = async (url: string, theme: TSupportedThemes = 'light'): Promise<void> => {
try { try {
const browser = UserPreferences.getString(DEFAULT_BROWSER_KEY); const browser = UserPreferences.getString(DEFAULT_BROWSER_KEY);
url = addProtocol(url);
if (browser === 'inApp') { if (browser === 'inApp') {
await WebBrowser.openBrowserAsync(url, { await WebBrowser.openBrowserAsync(url, {
toolbarColor: themes[theme].headerBackground, toolbarColor: themes[theme].headerBackground,