From 17d0f00a2e49db0207ba8e9bc304b0d4241f4c4a Mon Sep 17 00:00:00 2001 From: infiinte-persistence Date: Tue, 9 Jun 2020 06:10:20 +0200 Subject: [PATCH] Fix dev base-url being used when generating the hover URL --- electron/createWindow.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/electron/createWindow.js b/electron/createWindow.js index f8cb129f1..2420672ec 100644 --- a/electron/createWindow.js +++ b/electron/createWindow.js @@ -166,7 +166,24 @@ export default appState => { window.webContents.on('update-target-url', (event, url) => { // Change internal links to the lbry protocol. External (https) links should remain unchanged. - let dispUrl = url.replace(`http://localhost:${WEBPACK_ELECTRON_PORT}/`, lbryProto); + let hoverUrlBase = `http://localhost:${WEBPACK_ELECTRON_PORT}/`; + if (!isDev) { + // Return format of 'update-target-url': + // Linux: file:///@claim + // Windows: file:///C:/@claim + // Use '__dirname' in case installation is not in C: + const path = require('path'); + const exeRoot = path.parse(__dirname).root; + + if (process.platform === 'win32') { + // Add extra "/" prefix. Convert "C:\" to "C:/" + hoverUrlBase = `file:///` + exeRoot.replace(/\\/g, '/'); + } else { + hoverUrlBase = `file://` + exeRoot; + } + } + + let dispUrl = url.replace(hoverUrlBase, lbryProto); // Non-claims don't need the lbry protocol: if (dispUrl === lbryProto) { dispUrl = 'Home';