From 8f382ada86eac04214be9db776b819e5540af4a9 Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Tue, 18 Jan 2022 16:04:18 +0100 Subject: [PATCH] Remove deprecated substrings. (#830) --- .../rules/shared/actions/formattable-input.component.ts | 4 ++-- .../app/framework/angular/forms/control-errors.component.ts | 2 +- frontend/src/app/framework/angular/forms/error-validator.ts | 4 ++-- frontend/src/app/framework/angular/pipes/colors.pipes.ts | 2 +- frontend/src/app/framework/angular/pipes/money.pipe.ts | 2 +- frontend/src/app/framework/configurations.ts | 2 +- frontend/src/app/framework/services/localizer.service.ts | 2 +- frontend/src/app/framework/utils/error.spec.ts | 2 +- frontend/src/app/framework/utils/math-helper.ts | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/frontend/src/app/features/rules/shared/actions/formattable-input.component.ts b/frontend/src/app/features/rules/shared/actions/formattable-input.component.ts index 332f561d8..44cb45053 100644 --- a/frontend/src/app/features/rules/shared/actions/formattable-input.component.ts +++ b/frontend/src/app/features/rules/shared/actions/formattable-input.component.ts @@ -78,11 +78,11 @@ export class FormattableInputComponent implements ControlValueAccessor, AfterVie const lower = obj.toLowerCase(); if (lower.startsWith('liquid(')) { - this.value = obj.substr(7, obj.length - 8); + this.value = obj.substring(7, obj.length - 1); mode = 'Liquid'; } else if (lower.startsWith('script(')) { - this.value = obj.substr(7, obj.length - 8); + this.value = obj.substring(7, obj.length - 1); mode = 'Script'; } diff --git a/frontend/src/app/framework/angular/forms/control-errors.component.ts b/frontend/src/app/framework/angular/forms/control-errors.component.ts index 675b4916a..12a8b861e 100644 --- a/frontend/src/app/framework/angular/forms/control-errors.component.ts +++ b/frontend/src/app/framework/angular/forms/control-errors.component.ts @@ -56,7 +56,7 @@ export class ControlErrorsComponent extends StatefulComponent implements let translation = this.localizer.get(`common.${this.for}`)!; if (!translation) { - translation = this.for.substr(0, 1).toUpperCase() + this.for.substr(1); + translation = this.for.substring(0, 1).toUpperCase() + this.for.substring(1); } this.controlDisplayName = translation; diff --git a/frontend/src/app/framework/angular/forms/error-validator.ts b/frontend/src/app/framework/angular/forms/error-validator.ts index 444975a77..ab5679ab2 100644 --- a/frontend/src/app/framework/angular/forms/error-validator.ts +++ b/frontend/src/app/framework/angular/forms/error-validator.ts @@ -39,7 +39,7 @@ export class ErrorValidator { for (const details of this.error.details) { for (const property of details.properties) { if (property.startsWith(path)) { - const subProperty = property.substr(path.length); + const subProperty = property.substring(path.length); const first = subProperty[0]; @@ -50,7 +50,7 @@ export class ErrorValidator { errors.push(`${subProperty}: ${details.message}`); break; } else if (first === '.') { - errors.push(`${subProperty.substr(1)}: ${details.message}`); + errors.push(`${subProperty.substring(1)}: ${details.message}`); break; } } diff --git a/frontend/src/app/framework/angular/pipes/colors.pipes.ts b/frontend/src/app/framework/angular/pipes/colors.pipes.ts index 152bf6078..89863933b 100644 --- a/frontend/src/app/framework/angular/pipes/colors.pipes.ts +++ b/frontend/src/app/framework/angular/pipes/colors.pipes.ts @@ -58,7 +58,7 @@ const ColorDefinitions: ReadonlyArray = [ function parseColor(value: string) { if (value.charAt(0) === '#') { - value = value.substr(1, 6); + value = value.substring(1, 7); } value = value.replace(/ /g, '').toLowerCase(); diff --git a/frontend/src/app/framework/angular/pipes/money.pipe.ts b/frontend/src/app/framework/angular/pipes/money.pipe.ts index 2eeb91d04..652d14343 100644 --- a/frontend/src/app/framework/angular/pipes/money.pipe.ts +++ b/frontend/src/app/framework/angular/pipes/money.pipe.ts @@ -22,7 +22,7 @@ export class MoneyPipe implements PipeTransform { public transform(value: number): any { const money = value.toFixed(2).toString(); - let result = `${money.substr(0, money.length - 3) + this.separator.value}${money.substr(money.length - 2, 2)}`; + let result = `${money.substring(0, money.length - 3) + this.separator.value}${money.substring(money.length - 2)}`; if (this.currency.showAfter) { result = `${result} ${this.currency.symbol}`; diff --git a/frontend/src/app/framework/configurations.ts b/frontend/src/app/framework/configurations.ts index 6a1afe404..e014c23f6 100644 --- a/frontend/src/app/framework/configurations.ts +++ b/frontend/src/app/framework/configurations.ts @@ -47,7 +47,7 @@ export class ApiUrlConfig { public buildUrl(path: string) { if (path.indexOf('/') === 0) { - path = path.substr(1); + path = path.substring(1); } return this.value + path; diff --git a/frontend/src/app/framework/services/localizer.service.ts b/frontend/src/app/framework/services/localizer.service.ts index df209679f..0636180ae 100644 --- a/frontend/src/app/framework/services/localizer.service.ts +++ b/frontend/src/app/framework/services/localizer.service.ts @@ -56,7 +56,7 @@ export class LocalizerService { private replaceVariables(text: string, args: {}): string { text = text.replace(/{[^}]*}/g, (matched: string) => { - const inner = matched.substr(1, matched.length - 2); + const inner = matched.substring(1, matched.length - 1); let replaceValue: string; diff --git a/frontend/src/app/framework/utils/error.spec.ts b/frontend/src/app/framework/utils/error.spec.ts index c575c915b..4fa493f2e 100644 --- a/frontend/src/app/framework/utils/error.spec.ts +++ b/frontend/src/app/framework/utils/error.spec.ts @@ -17,7 +17,7 @@ describe('ErrorDto', () => { localizer = Mock.ofType(); localizer.setup(x => x.getOrKey(It.isAnyString())) - .returns((key: string) => key.substr(5)); + .returns((key: string) => key.substring(5)); }); it('should create simple message with error code', () => { diff --git a/frontend/src/app/framework/utils/math-helper.ts b/frontend/src/app/framework/utils/math-helper.ts index 0627efbad..9bdfc263f 100644 --- a/frontend/src/app/framework/utils/math-helper.ts +++ b/frontend/src/app/framework/utils/math-helper.ts @@ -146,7 +146,7 @@ export module MathHelper { } if (value.charAt(0) === '#') { - value = value.substr(1, 6); + value = value.substr(1, 7); } value = value.replace(/ /g, '').toLowerCase();