fix(tech): Replaced replaceAll methods with replace to avoid errors in some older browsers.

Squashed commit of the following:

commit 559c099720500a5fa55d92456cc555ab5d980e1f
Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se>
Date:   Thu Oct 14 13:14:16 2021 +0200

    Replaced replaceAll with replace method with regex to avoid older browser-problems
This commit is contained in:
Erik Tiekstra
2021-10-15 11:43:35 +02:00
parent 9a23e8b006
commit c68d69be3f
7 changed files with 7 additions and 10 deletions

View File

@@ -33,7 +33,7 @@ export class EmployeeInviteComponent {
get emailsControlValueAsArray(): string[] { get emailsControlValueAsArray(): string[] {
return (this.emailsControl.value as string) return (this.emailsControl.value as string)
.replaceAll(/\n|\t|\r/g, '') .replace(/\n|\t|\r/g, '')
.split(/[\s,;:]+/) .split(/[\s,;:]+/)
.filter(email => !!email); .filter(email => !!email);
} }

View File

@@ -63,9 +63,6 @@ export class LayoutComponent extends UnsubscribeDirective {
} }
get breadcrumbsItems(): NavigationBreadcrumbsItem[] { get breadcrumbsItems(): NavigationBreadcrumbsItem[] {
return this._breadcrumbsItems$.getValue().map(breadcrumb => ({ return this._breadcrumbsItems$.getValue();
...breadcrumb,
text: breadcrumb.text.replaceAll('-', ' '),
}));
} }
} }

View File

@@ -25,7 +25,7 @@ export function mapResponseToContactInformation(data: ContactInformationResponse
firstName: fornamn || '', firstName: fornamn || '',
lastName: efternamn || '', lastName: efternamn || '',
fullName: fornamn && efternamn ? `${fornamn} ${efternamn}` : '', fullName: fornamn && efternamn ? `${fornamn} ${efternamn}` : '',
ssn: personnummer ? mapStringToSsn(personnummer) : '', ssn: mapStringToSsn(personnummer),
email: epost || '', email: epost || '',
phoneNumbers: telekomadresser phoneNumbers: telekomadresser
? telekomadresser ? telekomadresser

View File

@@ -57,7 +57,7 @@ export function mapResponseToEmployee(data: EmployeeResponse): Employee {
lastName, lastName,
fullName: `${firstName} ${lastName}`, fullName: `${firstName} ${lastName}`,
email, email,
ssn: ssn ? mapStringToSsn(ssn) : null, ssn: mapStringToSsn(ssn),
roles: roles || [], roles: roles || [],
tjanster: tjanster?.map(tjanst => mapResponseToEmployeeTjanst(tjanst)), tjanster: tjanster?.map(tjanst => mapResponseToEmployeeTjanst(tjanst)),
allaUtforandeVerksamheter, allaUtforandeVerksamheter,

View File

@@ -9,7 +9,7 @@ export function mapPathsToBreadcrumbs(
let breadcrumbs = [ let breadcrumbs = [
...(startBreadcrumb ? [startBreadcrumb] : []), ...(startBreadcrumb ? [startBreadcrumb] : []),
...paths.map((path, index) => ({ ...paths.map((path, index) => ({
text: mapPathToPageName(path), text: mapPathToPageName(path).replace(/-/g, ' '),
routerLink: `/${paths.slice(0, index + 1).join('/')}`, routerLink: `/${paths.slice(0, index + 1).join('/')}`,
})), })),
]; ];

View File

@@ -1,7 +1,7 @@
const CURRENT_YEAR = new Date().getFullYear().toString().slice(2, 4); const CURRENT_YEAR = new Date().getFullYear().toString().slice(2, 4);
export function mapStringToSsn(ssn: string): string { export function mapStringToSsn(ssn: string): string {
ssn = ssn.replaceAll('-', ''); ssn = (ssn || '').replace(/-/g, '');
if (ssn.length === 10) { if (ssn.length === 10) {
const century = +CURRENT_YEAR - +ssn.slice(0, 2) > 0 ? '20' : '19'; const century = +CURRENT_YEAR - +ssn.slice(0, 2) > 0 ? '20' : '19';
ssn = ssn.padStart(12, century); ssn = ssn.padStart(12, century);

View File

@@ -25,7 +25,7 @@ export function CommaSeparatedEmailValidator(): ValidatorFn {
if (control && control.value) { if (control && control.value) {
const values: string[] = (control.value as string) const values: string[] = (control.value as string)
.toLowerCase() .toLowerCase()
.replaceAll(/\n|\t|\r/g, '') .replace(/\n|\t|\r/g, '')
.split(/[\s,;:]+/); .split(/[\s,;:]+/);
const invalidEmailaddresses = []; const invalidEmailaddresses = [];