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) {
148
148
return null ;
149
149
}
150
150
151
+
151
152
/**
152
153
* Prepare list of logins based on provided files
153
154
*
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ const m = require("mithril");
5
5
const dialog = require ( "../popup/modalDialog" ) ;
6
6
const notify = require ( "../popup/notifications" ) ;
7
7
const helpers = require ( "../helpers/base" ) ;
8
+ const BrowserpassURL = require ( "@browserpass/url" ) ;
8
9
9
10
const containsNumbersRegEx = RegExp ( / [ 0 - 9 ] / ) ;
10
11
const containsSymbolsRegEx = RegExp ( / [ \p{ P} \p{ S} ] / , "u" ) ;
@@ -13,6 +14,7 @@ module.exports = {
13
14
handleError,
14
15
highlight,
15
16
withLogin,
17
+ getCurrentUrl
16
18
} ;
17
19
18
20
//----------------------------------- Function definitions ----------------------------------//
@@ -152,3 +154,19 @@ async function withLogin(action, params = {}) {
152
154
handleError ( e ) ;
153
155
}
154
156
}
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) {
305
305
} else {
306
306
// view instance should be a Login
307
307
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 : "" ;
308
313
}
309
314
310
315
// set the storePath and get tree dirs
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ module.exports = SearchInterface;
3
3
const BrowserpassURL = require ( "@browserpass/url" ) ;
4
4
const dialog = require ( "./modalDialog" ) ;
5
5
const helpers = require ( "../helpers/base" ) ;
6
+ const helpersUI = require ( "../helpers/ui" ) ;
6
7
const m = require ( "mithril" ) ;
7
8
8
9
/**
@@ -33,15 +34,8 @@ function SearchInterface(popup) {
33
34
function view ( ctl , params ) {
34
35
var self = this ;
35
36
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 : "" ;
45
39
46
40
return m (
47
41
"form.part.search" ,
You can’t perform that action at this time.
0 commit comments