зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1563769 - Compile the regular expressions for computing the login title only once. r=MattN
Differential Revision: https://phabricator.services.mozilla.com/D37106 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
06ba061c26
Коммит
9367744c2b
|
@ -69,14 +69,16 @@ const convertSubjectToLogin = subject => {
|
|||
return augmentVanillaLoginObject(login);
|
||||
};
|
||||
|
||||
const SCHEME_REGEX = new RegExp(/^http(s)?:\/\//);
|
||||
const SUBDOMAIN_REGEX = new RegExp(/^www\d*\./);
|
||||
const augmentVanillaLoginObject = login => {
|
||||
let title;
|
||||
try {
|
||||
title = new URL(login.origin).host;
|
||||
} catch (ex) {
|
||||
title = login.origin;
|
||||
title = login.origin.replace(SCHEME_REGEX, "");
|
||||
}
|
||||
title = title.replace(/^http(s)?:\/\//, "").replace(/^www\d*\./, "");
|
||||
title = title.replace(SUBDOMAIN_REGEX, "");
|
||||
return Object.assign({}, login, {
|
||||
title,
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче