From 52b8992cbf960e001336d59b83c610845ff35860 Mon Sep 17 00:00:00 2001 From: Shinigami Date: Sun, 18 Feb 2024 23:56:40 +0100 Subject: infra(unicorn): prefer-string-replace-all (#2653) --- src/modules/helpers/index.ts | 8 ++++---- src/modules/helpers/luhn-check.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/modules/helpers') diff --git a/src/modules/helpers/index.ts b/src/modules/helpers/index.ts index 635b3e09..73728f78 100644 --- a/src/modules/helpers/index.ts +++ b/src/modules/helpers/index.ts @@ -228,9 +228,9 @@ export class SimpleHelpersModule extends SimpleModuleBase { slugify(string: string = ''): string { return string .normalize('NFKD') //for example è decomposes to as e + ̀ - .replace(/[\u0300-\u036F]/g, '') // removes combining marks - .replace(/ /g, '-') // replaces spaces with hyphens - .replace(/[^\w.-]+/g, ''); // removes all non-word characters except for dots and hyphens + .replaceAll(/[\u0300-\u036F]/g, '') // removes combining marks + .replaceAll(' ', '-') // replaces spaces with hyphens + .replaceAll(/[^\w.-]+/g, ''); // removes all non-word characters except for dots and hyphens } /** @@ -797,7 +797,7 @@ export class SimpleHelpersModule extends SimpleModuleBase { let value = data[p]; if (typeof value === 'string') { // escape $, source: https://stackoverflow.com/a/6969486/6897682 - value = value.replace(/\$/g, '$$$$'); + value = value.replaceAll('$', '$$$$'); str = str.replace(re, value); } else { str = str.replace(re, value); diff --git a/src/modules/helpers/luhn-check.ts b/src/modules/helpers/luhn-check.ts index 42fbe1a5..fd7d54cc 100644 --- a/src/modules/helpers/luhn-check.ts +++ b/src/modules/helpers/luhn-check.ts @@ -24,7 +24,7 @@ export function luhnCheckValue(str: string): number { * @param str The string to generate the checksum for. */ function luhnChecksum(str: string): number { - str = str.replace(/[\s-]/g, ''); + str = str.replaceAll(/[\s-]/g, ''); let sum = 0; let alternate = false; for (let i = str.length - 1; i >= 0; i--) { -- cgit v1.2.3