File tree Expand file tree Collapse file tree 3 files changed +23
-9
lines changed Expand file tree Collapse file tree 3 files changed +23
-9
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ module.exports = {
3535 isChrome,
3636 makeTOTP,
3737 parseAuthUrl,
38+ getCurrentUrl,
3839 prepareLogin,
3940 prepareLogins,
4041 unsecureRequestWarning,
@@ -148,6 +149,22 @@ function parseAuthUrl(url) {
148149 return null ;
149150}
150151
152+ /**
153+ * Returns current url
154+ * @param object settings Settings object to use
155+ * @returns string
156+ */
157+ function getCurrentUrl ( settings ) {
158+ let url = "" ;
159+ const authUrl = parseAuthUrl ( window ?. location ?. href ?? null ) ;
160+ if ( settings . authRequested && authUrl ) {
161+ url = new BrowserpassURL ( authUrl ) ;
162+ } else {
163+ url = new BrowserpassURL ( settings . origin ) ;
164+ }
165+ return url
166+ }
167+
151168/**
152169 * Prepare list of logins based on provided files
153170 *
Original file line number Diff line number Diff line change @@ -284,6 +284,11 @@ function AddEditInterface(settingsModel) {
284284 } else {
285285 // view instance should be a Login
286286 loginObj = new Login ( settings ) ;
287+
288+ const url = helpers . getCurrentUrl ( settings ) ;
289+
290+ // prefill the host of the current tab
291+ loginObj . login = url . isValid ? url . hostname : "" ;
287292 }
288293
289294 // set the storePath and get tree dirs
Original file line number Diff line number Diff line change @@ -33,15 +33,7 @@ function SearchInterface(popup) {
3333function view ( ctl , params ) {
3434 var self = this ;
3535
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 ;
36+ const host = helpers . getCurrentUrl ( this . popup . settings ) . hostname ;
4537
4638 return m (
4739 "form.part.search" ,
You can’t perform that action at this time.
0 commit comments