File tree Expand file tree Collapse file tree 4 files changed +27
-9
lines changed Expand file tree Collapse file tree 4 files changed +27
-9
lines changed Original file line number Diff line number Diff line change @@ -148,6 +148,7 @@ function parseAuthUrl(url) {
148148 return null ;
149149}
150150
151+
151152/**
152153 * Prepare list of logins based on provided files
153154 *
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ const m = require("mithril");
55const dialog = require ( "../popup/modalDialog" ) ;
66const notify = require ( "../popup/notifications" ) ;
77const helpers = require ( "../helpers/base" ) ;
8+ const BrowserpassURL = require ( "@browserpass/url" ) ;
89
910const containsNumbersRegEx = RegExp ( / [ 0 - 9 ] / ) ;
1011const containsSymbolsRegEx = RegExp ( / [ \p{ P} \p{ S} ] / , "u" ) ;
@@ -13,6 +14,7 @@ module.exports = {
1314 handleError,
1415 highlight,
1516 withLogin,
17+ getCurrentUrl
1618} ;
1719
1820//----------------------------------- Function definitions ----------------------------------//
@@ -152,3 +154,19 @@ async function withLogin(action, params = {}) {
152154 handleError ( e ) ;
153155 }
154156}
157+
158+ /**
159+ * Returns current url
160+ * @param object settings Settings object to use
161+ * @returns object Instance of BrowserpassURL
162+ */
163+ function getCurrentUrl ( settings ) {
164+ let url ;
165+ const authUrl = helpers . parseAuthUrl ( window ?. location ?. href ?? null ) ;
166+ if ( settings . authRequested && authUrl ) {
167+ url = new BrowserpassURL ( authUrl ) ;
168+ } else {
169+ url = new BrowserpassURL ( settings . origin ) ;
170+ }
171+ return url
172+ }
Original file line number Diff line number Diff line change @@ -305,6 +305,11 @@ function AddEditInterface(settingsModel) {
305305 } else {
306306 // view instance should be a Login
307307 loginObj = new Login ( settings ) ;
308+
309+ const url = helpersUI . getCurrentUrl ( settings ) ;
310+
311+ // prefill the host of the current tab
312+ loginObj . login = url . isValid ? url . hostname : "" ;
308313 }
309314
310315 // set the storePath and get tree dirs
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ module.exports = SearchInterface;
33const BrowserpassURL = require ( "@browserpass/url" ) ;
44const dialog = require ( "./modalDialog" ) ;
55const helpers = require ( "../helpers/base" ) ;
6+ const helpersUI = require ( "../helpers/ui" ) ;
67const m = require ( "mithril" ) ;
78
89/**
@@ -33,15 +34,8 @@ function SearchInterface(popup) {
3334function view ( ctl , params ) {
3435 var self = this ;
3536
36- let url = "" ;
37- const authUrl = helpers . parseAuthUrl ( window ?. location ?. href ?? null ) ;
38- if ( this . popup . settings . authRequested && authUrl ) {
39- url = new BrowserpassURL ( authUrl ) ;
40- } else {
41- url = new BrowserpassURL ( this . popup . settings . origin ) ;
42- }
43-
44- const host = url . hostname ;
37+ const url = helpersUI . getCurrentUrl ( this . popup . settings ) ;
38+ const host = url . isValid ? url . hostname : "" ;
4539
4640 return m (
4741 "form.part.search" ,
You can’t perform that action at this time.
0 commit comments