зеркало из 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);
|
return augmentVanillaLoginObject(login);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const SCHEME_REGEX = new RegExp(/^http(s)?:\/\//);
|
||||||
|
const SUBDOMAIN_REGEX = new RegExp(/^www\d*\./);
|
||||||
const augmentVanillaLoginObject = login => {
|
const augmentVanillaLoginObject = login => {
|
||||||
let title;
|
let title;
|
||||||
try {
|
try {
|
||||||
title = new URL(login.origin).host;
|
title = new URL(login.origin).host;
|
||||||
} catch (ex) {
|
} 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, {
|
return Object.assign({}, login, {
|
||||||
title,
|
title,
|
||||||
});
|
});
|
||||||
|
|
Загрузка…
Ссылка в новой задаче