[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;
};
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> => {
try {
const browser = UserPreferences.getString(DEFAULT_BROWSER_KEY);
url = addProtocol(url);
if (browser === 'inApp') {
await WebBrowser.openBrowserAsync(url, {
toolbarColor: themes[theme].headerBackground,