const { url, summary, logo, name } = properties;
parts.push('<span class="client-identifier">');
- if (url && url.length) {
+ if (url?.length) {
parts.push(`<a href="${url[0]}">`);
}
- if (summary && summary.length) {
+ if (summary?.length) {
imgTitle = ` title="${summary[0]}"`;
}
- if (logo && logo.length) {
+ if (logo?.length) {
let src, alt;
if (typeof logo[0] === 'string') {
src = logo[0];
}
parts.push(`<img src="${src}" alt="${alt}"${imgTitle}>`);
}
- if (name && name.length) {
+ if (name?.length) {
parts.push(properties['name'][0]);
}
- if (url && url.length) {
+ if (url?.length) {
parts.push('</a>');
}
parts.push('</span>');
* @returns {String}
*/
function renderClientIdentifier(clientIdentifier) {
- const hAppEntries = clientIdentifier && clientIdentifier.items || [];
+ const hAppEntries = clientIdentifier?.items || [];
return hAppEntries.map(renderClientIdentifierProperties).join('');
}
*/
function renderProfileFieldset(availableProfiles, hintProfile) {
if (!availableProfiles || availableProfiles.length <= 1) {
- const profile = availableProfiles && availableProfiles[0] || hintProfile;
+ const profile = availableProfiles?.[0] || hintProfile;
return `<input type="hidden" name="me" value="${profile}">`;
}
return `
scopeDescription = '';
}
let profileClass;
- if (scope.profiles && scope.profiles.length) {
+ if (scope.profiles?.length) {
profileClass = ['profile-scope'].concat(scope.profiles.map((profile) => th.escapeCSS(profile))).join(' ');
} else {
profileClass = '';
function renderRequestedScopes(requestedScopes) {
- if (!requestedScopes || !requestedScopes.length) {
+ if (!requestedScopes?.length) {
return '';
}
return `
*/
function mainContent(ctx, options) { // eslint-disable-line no-unused-vars
const session = ctx.session || {};
- const hintedProfile = (session.me && session.me.href) || (session.profiles && session.profiles.length && session.profiles[0]) || '';
+ const hintedProfile = session.me?.href || session.profiles?.[0] || '';
const scopeIndex = session.scopeIndex || {};
- // Add requested scopes to index, if not already present,
- // and de-associate requested scopes from profiles.
+ /**
+ * Add requested scopes to index, if not already present,
+ * and de-associate requested scopes from profiles.
+ */
const scopes = session.scope || [];
scopes.forEach((scopeName) => {
if ((scopeName in scopeIndex)) {