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

Commit

Permalink
(Attempt to) get rid of deprecated app dep wurl
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ronjouch committed Feb 25, 2021
1 parent fe79fd6 commit 6b266b7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
3 changes: 1 addition & 2 deletions app/package.json
Expand Up @@ -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"
Expand Down
17 changes: 13 additions & 4 deletions app/src/helpers/helpers.ts
Expand Up @@ -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');

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 6b266b7

Please sign in to comment.