revert regex.exec to string.match

This commit is contained in:
Ulf Gebhardt 2023-03-09 14:20:23 +01:00
parent 09d2db3028
commit b530576a84
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
4 changed files with 5 additions and 5 deletions

View File

@ -128,7 +128,7 @@ export class TransactionLinkResolver {
@Authorized([RIGHTS.QUERY_TRANSACTION_LINK]) @Authorized([RIGHTS.QUERY_TRANSACTION_LINK])
@Query(() => QueryLinkResult) @Query(() => QueryLinkResult)
async queryTransactionLink(@Arg('code') code: string): Promise<typeof QueryLinkResult> { async queryTransactionLink(@Arg('code') code: string): Promise<typeof QueryLinkResult> {
if (/^CL-/.exec(code)) { if (code.match(/^CL-/)) {
const contributionLink = await DbContributionLink.findOneOrFail( const contributionLink = await DbContributionLink.findOneOrFail(
{ code: code.replace('CL-', '') }, { code: code.replace('CL-', '') },
{ withDeleted: true }, { withDeleted: true },
@ -154,7 +154,7 @@ export class TransactionLinkResolver {
const clientTimezoneOffset = getClientTimezoneOffset(context) const clientTimezoneOffset = getClientTimezoneOffset(context)
const user = getUser(context) const user = getUser(context)
if (/^CL-/.exec(code)) { if (code.match(/^CL-/)) {
// acquire lock // acquire lock
const releaseLock = await TRANSACTIONS_LOCK.acquire() const releaseLock = await TRANSACTIONS_LOCK.acquire()
try { try {

View File

@ -280,7 +280,7 @@ export class UserResolver {
dbUser.passwordEncryptionType = PasswordEncryptionType.NO_PASSWORD dbUser.passwordEncryptionType = PasswordEncryptionType.NO_PASSWORD
logger.debug('new dbUser', dbUser) logger.debug('new dbUser', dbUser)
if (redeemCode) { if (redeemCode) {
if (/^CL-/.exec(redeemCode)) { if (redeemCode.match(/^CL-/)) {
const contributionLink = await DbContributionLink.findOne({ const contributionLink = await DbContributionLink.findOne({
code: redeemCode.replace('CL-', ''), code: redeemCode.replace('CL-', ''),
}) })

View File

@ -12,7 +12,7 @@ const sodium = require('sodium-native')
// We will reuse this for changePassword // We will reuse this for changePassword
export const isValidPassword = (password: string): boolean => { export const isValidPassword = (password: string): boolean => {
return !!/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[^a-zA-Z0-9 \\t\\n\\r]).{8,}$/.exec(password) return !!password.match(/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[^a-zA-Z0-9 \\t\\n\\r]).{8,}$/)
} }
export const SecretKeyCryptographyCreateKey = (salt: string, password: string): Buffer[] => { export const SecretKeyCryptographyCreateKey = (salt: string, password: string): Buffer[] => {

View File

@ -119,7 +119,7 @@ export const elopageWebhook = async (req: any, res: any): Promise<void> => {
// Validate inputs // Validate inputs
if ( if (
email === '' || email === '' ||
!VALIDATE_EMAIL.exec(email) || !email.match(VALIDATE_EMAIL) ||
firstName === '' || firstName === '' ||
firstName.match(VALIDATE_NAME) || firstName.match(VALIDATE_NAME) ||
lastName === '' || lastName === '' ||