From a18531cb811f88969e7c15dbde5aac2ad0dafbe9 Mon Sep 17 00:00:00 2001 From: ebith Date: Sat, 12 May 2018 04:27:01 +0900 Subject: [PATCH] Fix video popup --- src/main.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main.js b/src/main.js index 8ca8ad9..ff60f75 100644 --- a/src/main.js +++ b/src/main.js @@ -1,6 +1,6 @@ import {app, BrowserWindow, shell} from 'electron'; import path from 'path'; -import url from 'url'; +import libUrl from 'url'; import Store from 'electron-store'; import loadDevtool from 'electron-load-devtool'; import Auth from './auth'; @@ -35,7 +35,8 @@ const createWindow = () => { win.webContents.on('new-window', (event, url) => { event.preventDefault(); - if (/\.(jpg|png|gif|mp4)$/.test(url)) { + const pathname = new libUrl.URL(url).pathname; + if (/\.(jpg|png|gif|mp4)$/.test(pathname)) { const popup = new BrowserWindow({show: false}); popup.once('ready-to-show', () => { popup.webContents.executeJavaScript(` @@ -81,7 +82,7 @@ const createWindow = () => { }); win.loadURL( - url.format({ + libUrl.format({ pathname: path.join(__dirname, 'index.html'), protocol: 'file:', slashes: true,