Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
fix(main): fix url parsing issue with lightning links
Browse files Browse the repository at this point in the history
  • Loading branch information
mrfelton committed Dec 15, 2018
1 parent 66ee212 commit a9da2b0
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions app/main.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,18 @@ app.on('ready', async () => {
/**
* Handler for lightning: links
*/
const handleLightningLink = payReq => {
const handleLightningLink = input => {
const payReq = input.split(':')[1]
zap.sendMessage('lightningPaymentUri', { payReq })
zap.mainWindow.show()
}

/**
* Handler for lndconnect: links
*/
const handleLndconnectLink = query => {
const { host, cert, macaroon } = querystring.parse(query)
const handleLndconnectLink = input => {
const parsedUrl = url.parse(input)
const { host, cert, macaroon } = querystring.parse(parsedUrl.query)
zap.sendMessage('lndconnectUri', { host, cert, macaroon })
zap.mainWindow.show()
}
Expand All @@ -193,15 +195,15 @@ app.on('ready', async () => {
mainLog.debug('open-url: %s', input)
event.preventDefault()

const parsedUrl = url.parse(input)
const type = input.split(':')[0]

switch (parsedUrl.protocol) {
case 'lightning:':
handleLightningLink(parsedUrl.host)
switch (type) {
case 'lightning':
handleLightningLink(input)
break

case 'lndconnect:':
handleLndconnectLink(parsedUrl.query)
case 'lndconnect':
handleLndconnectLink(input)
}
})

Expand Down

0 comments on commit a9da2b0

Please sign in to comment.