(Attempt to) get rid of deprecated app dep `wurl`

This one may be problematic, as it used to do TLD stuff:
https://github.com/websanova/node-url/blob/7982a613bc/wurl.js#L4

So, the new WHATWG-URL-based implementation will consider
`asana.com` to be "external" to `app.asana.com`, contrarily to before.
Given the nature of Nativefier, I think it's actually what to expect,
that in this case your "out of the app", and in e.g. asana landing's page,
which you'd expect to see in your browser.

Let's see if users disagree with that.
This commit is contained in:
Ronan Jouchet 2021-02-25 18:48:00 -05:00
parent fe79fd622d
commit 6b266b7815
2 changed files with 14 additions and 6 deletions

View File

@ -16,8 +16,7 @@
"electron-dl": "^3.1.0",
"electron-squirrel-startup": "^1.0.0",
"electron-window-state": "^5.0.3",
"source-map-support": "^0.5.19",
"wurl": "^2.5.4"
"source-map-support": "^0.5.19"
},
"devDependencies": {
"electron": "^11.3.0"

View File

@ -3,7 +3,6 @@ import * as os from 'os';
import * as path from 'path';
import { BrowserWindow } from 'electron';
import wurl from 'wurl';
const INJECT_CSS_PATH = path.join(__dirname, '..', 'inject/inject.css');
@ -33,9 +32,19 @@ export function linkIsInternal(
return regex.test(newUrl);
}
const currentDomain = wurl('domain', currentUrl);
const newDomain = wurl('domain', newUrl);
return currentDomain === newDomain;
try {
const currentDomain = new URL(currentUrl).hostname;
const newDomain = new URL(newUrl).hostname;
return currentDomain === newDomain;
} catch (err) {
console.warn(
'Failed to parse domains as determining if link is internal. From:',
currentUrl,
'To:',
newUrl,
);
return false;
}
}
export function shouldInjectCss(): boolean {