-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve opening links in web browser
- Loading branch information
1 parent
447d339
commit a1a3cf0
Showing
5 changed files
with
25 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { BrowserOpenURL } from '../../wailsjs/runtime'; | ||
|
||
// Opens the URL in the default web browser | ||
// If the URL does not contain the protocol and host parts, we prepend VITE_BASE_API | ||
export const openInWebBrowser = (url: string) => { | ||
if (!url.includes('://')) { | ||
if (url.startsWith('/')) { | ||
url = `${import.meta.env.VITE_BASE_API}${url}`; | ||
} else { | ||
url = `${import.meta.env.VITE_BASE_API}/${url}`; | ||
} | ||
} | ||
|
||
// eslint-disable-next-line new-cap | ||
BrowserOpenURL(url); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters