2019-12-26 22:10:19 +05:30
|
|
|
const DEFAULT_TITLE = '· GitLab';
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
export const setTitle = (pathMatch, ref, project) => {
|
2019-12-26 22:10:19 +05:30
|
|
|
if (!pathMatch) {
|
|
|
|
document.title = `${project} ${DEFAULT_TITLE}`;
|
|
|
|
return;
|
|
|
|
}
|
2019-09-04 21:01:54 +05:30
|
|
|
|
|
|
|
const path = pathMatch.replace(/^\//, '');
|
|
|
|
const isEmpty = path === '';
|
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
/* eslint-disable-next-line @gitlab/require-i18n-strings */
|
2019-12-26 22:10:19 +05:30
|
|
|
document.title = `${isEmpty ? 'Files' : path} · ${ref} · ${project} ${DEFAULT_TITLE}`;
|
2019-09-04 21:01:54 +05:30
|
|
|
};
|
2020-03-13 15:44:24 +05:30
|
|
|
|
|
|
|
export function updateRefPortionOfTitle(sha, doc = document) {
|
|
|
|
const { title = '' } = doc;
|
|
|
|
const titleParts = title.split(' · ');
|
|
|
|
|
|
|
|
if (titleParts.length > 1) {
|
|
|
|
titleParts[1] = sha;
|
|
|
|
|
|
|
|
/* eslint-disable-next-line no-param-reassign */
|
|
|
|
doc.title = titleParts.join(' · ');
|
|
|
|
}
|
|
|
|
}
|