Skip to content

Commit

Permalink
links: add copy to clipboard option (#377)
Browse files Browse the repository at this point in the history
Co-authored-by: Brendan Meyer <brendanmeyer@gmail.com>
  • Loading branch information
brendanmeyer and Brendan Meyer authored Jul 6, 2023
1 parent 2269aa6 commit 7791d17
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main/utils/url.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { dialog, shell } from 'electron'
import { clipboard, dialog, shell } from 'electron'
import config, { ConfigKey } from '../config'

export function cleanURLFromGoogle(url: string): string {
Expand All @@ -19,12 +19,17 @@ export async function openExternalUrl(url: string): Promise<void> {
if (!trustedHosts.includes(origin)) {
const { response, checkboxChecked } = await dialog.showMessageBox({
type: 'info',
buttons: ['Open Link', 'Cancel'],
buttons: ['Open Link', 'Copy Link', 'Cancel'],
message: `Do you want to open this external link in your default browser?`,
checkboxLabel: `Trust all links on ${origin}`,
detail: cleanURL
})

if (response === 1) {
clipboard.writeText(cleanURL)
return
}

if (response !== 0) return

if (checkboxChecked) {
Expand Down

0 comments on commit 7791d17

Please sign in to comment.