From f0c2dc6b847e2fa3b96f422a36fab34b49c85448 Mon Sep 17 00:00:00 2001 From: Johnny Zabala Date: Wed, 12 Aug 2020 23:50:53 -0400 Subject: [PATCH] feat(desktop-app): add file schema on address bar for filesystem paths --- desktop-app/app/components/Addressinput/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/desktop-app/app/components/Addressinput/index.js b/desktop-app/app/components/Addressinput/index.js index 74b02763..3db7938f 100644 --- a/desktop-app/app/components/Addressinput/index.js +++ b/desktop-app/app/components/Addressinput/index.js @@ -5,6 +5,7 @@ import FavIconOff from '@material-ui/icons/StarBorder'; import FavIconOn from '@material-ui/icons/Star'; import {Tooltip} from '@material-ui/core'; import {Icon} from 'flwww'; +import fs from 'fs'; import HomePlusIcon from '../icons/HomePlus'; import DeleteCookieIcon from '../icons/DeleteCookie'; import DeleteStorageIcon from '../icons/DeleteStorage'; @@ -252,11 +253,13 @@ class AddressBar extends React.Component { }); }; - _normalize = address => { + _normalize = (address: string) => { if (address.indexOf('://') === -1) { let protocol = 'https://'; if (address.startsWith('localhost') || address.startsWith('127.0.0.1')) { protocol = 'http://'; + } else if (fs.existsSync(address)) { + protocol = 'file://'; } address = `${protocol}${address}`; }