Improve SGU logon resilience and client UX
This commit is contained in:
@@ -27,11 +27,11 @@ public static class SguProfileParser
|
||||
|
||||
InstitutionalProfile profile = new(
|
||||
EmployeeNumber: employeeNumber,
|
||||
DisplayName: Limit(displayName, 256),
|
||||
DisplayName: NormalizeTitle(displayName, 256),
|
||||
Email: NormalizeEmail(ExtractSpanText(html, EmailId)),
|
||||
EmployeeType: Limit(ExtractSpanText(html, EmployeeTypeId), 256),
|
||||
JobTitle: Limit(ExtractSpanText(html, JobTitleId), 64),
|
||||
Department: Limit(ExtractSpanText(html, DepartmentId), 64));
|
||||
EmployeeType: NormalizeSentence(ExtractSpanText(html, EmployeeTypeId), 256),
|
||||
JobTitle: NormalizeTitle(ExtractSpanText(html, JobTitleId), 64),
|
||||
Department: NormalizeTitle(ExtractSpanText(html, DepartmentId), 64));
|
||||
return profile.HasValues ? profile : null;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public static class SguProfileParser
|
||||
ArgumentNullException.ThrowIfNull(html);
|
||||
|
||||
InstitutionalProfile profile = new(
|
||||
DisplayName: Limit(ExtractSpanText(html, MenuNameId), 256));
|
||||
DisplayName: NormalizeTitle(ExtractSpanText(html, MenuNameId), 256));
|
||||
return profile.HasValues ? profile : null;
|
||||
}
|
||||
|
||||
@@ -167,13 +167,27 @@ public static class SguProfileParser
|
||||
return null;
|
||||
}
|
||||
|
||||
return address.Address;
|
||||
return address.Address.ToLowerInvariant();
|
||||
}
|
||||
|
||||
private static string? NormalizeTitle(string? value, int maximumLength)
|
||||
{
|
||||
string? candidate = Limit(value, maximumLength);
|
||||
return candidate is null ? null : SpanishTextNormalizer.ToTitleCase(candidate);
|
||||
}
|
||||
|
||||
private static string? NormalizeSentence(string? value, int maximumLength)
|
||||
{
|
||||
string? candidate = Limit(value, maximumLength);
|
||||
return candidate is null ? null : SpanishTextNormalizer.ToSentenceCase(candidate);
|
||||
}
|
||||
|
||||
private static string? Limit(string? value, int maximumLength)
|
||||
{
|
||||
string? candidate = value?.Trim();
|
||||
return string.IsNullOrEmpty(candidate) || candidate.Length > maximumLength
|
||||
return string.IsNullOrEmpty(candidate) ||
|
||||
candidate.Length > maximumLength ||
|
||||
candidate.Contains('\uFFFD')
|
||||
? null
|
||||
: candidate;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user