Skip to content

Commit

Permalink
Fix - New Tab URLs not opening
Browse files Browse the repository at this point in the history
  • Loading branch information
kamranahmedse committed Nov 3, 2018
1 parent 8286edf commit 666aa1e
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/components/web-page/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import * as NProgress from 'nprogress';
import parseUrl from 'url-parse';

import './style.scss';
import NavBar from '../nav-bar';
Expand Down Expand Up @@ -37,6 +38,19 @@ class WebPage extends React.Component {
currentWebView.addEventListener('did-stop-loading', () => {
NProgress.done();
});

currentWebView.addEventListener('new-window', (event) => {
const currentUrl = this.webView.current.getURL();
const newUrl = event.url;

const parsedCurrentUrl = parseUrl(currentUrl, true);
const parsedNewUrl = parseUrl(newUrl, true);

// Only allow opening windows from current domain to avoid ads-popups
if (parsedNewUrl.host === parsedCurrentUrl.host) {
this.props.onUrl(newUrl);
}
});
}

onReload = () => {
Expand Down Expand Up @@ -91,7 +105,7 @@ class WebPage extends React.Component {
/>
}
<webview
plugins
plugins="true"
useragent={ USER_AGENT }
ref={ this.webView }
id="view"
Expand Down

0 comments on commit 666aa1e

Please sign in to comment.