зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1549814 - Include a title with the login object that removes http(s) or www prefix. r=MattN
Differential Revision: https://phabricator.services.mozilla.com/D31711 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
e1dee87910
Коммит
0323332d31
|
@ -39,12 +39,26 @@ const isValidLogin = login => {
|
|||
};
|
||||
|
||||
const convertSubjectToLogin = subject => {
|
||||
subject.QueryInterface(Ci.nsILoginMetaInfo).QueryInterface(Ci.nsILoginInfo);
|
||||
const login = LoginHelper.loginToVanillaObject(subject);
|
||||
if (!isValidLogin(login)) {
|
||||
return null;
|
||||
}
|
||||
return login;
|
||||
subject.QueryInterface(Ci.nsILoginMetaInfo).QueryInterface(Ci.nsILoginInfo);
|
||||
const login = LoginHelper.loginToVanillaObject(subject);
|
||||
if (!isValidLogin(login)) {
|
||||
return null;
|
||||
}
|
||||
return augmentVanillaLoginObject(login);
|
||||
};
|
||||
|
||||
const augmentVanillaLoginObject = login => {
|
||||
let title;
|
||||
try {
|
||||
title = (new URL(login.hostname)).host;
|
||||
} catch (ex) {
|
||||
title = login.hostname;
|
||||
}
|
||||
title = title.replace(/^http(s)?:\/\//, "").
|
||||
replace(/^www\d*\./, "");
|
||||
return Object.assign({}, login, {
|
||||
title,
|
||||
});
|
||||
};
|
||||
|
||||
var AboutLoginsParent = {
|
||||
|
@ -232,6 +246,7 @@ var AboutLoginsParent = {
|
|||
return Services.logins
|
||||
.getAllLogins()
|
||||
.filter(isValidLogin)
|
||||
.map(LoginHelper.loginToVanillaObject);
|
||||
.map(LoginHelper.loginToVanillaObject)
|
||||
.map(augmentVanillaLoginObject);
|
||||
},
|
||||
};
|
||||
|
|
|
@ -110,8 +110,7 @@ class LoginItem extends ReflectedFluentElement {
|
|||
timeUsed: this._login.timeLastUsed || "",
|
||||
};
|
||||
document.l10n.setAttributes(this, "login-item", l10nArgs);
|
||||
let hostnameNoScheme = this._login.hostname && new URL(this._login.hostname).hostname;
|
||||
this.shadowRoot.querySelector(".title").textContent = hostnameNoScheme || "";
|
||||
this.shadowRoot.querySelector(".title").textContent = this._login.title || "";
|
||||
this.shadowRoot.querySelector(".hostname").textContent = this._login.hostname || "";
|
||||
this.shadowRoot.querySelector("modal-input[name='username']").setAttribute("value", this._login.username || "");
|
||||
this.shadowRoot.querySelector("modal-input[name='password']").setAttribute("value", this._login.password || "");
|
||||
|
|
Загрузка…
Ссылка в новой задаче