mirror of
https://github.com/hexastack/hexabot
synced 2025-04-18 13:28:50 +00:00
fix: use lodash package
This commit is contained in:
parent
fcfc68187b
commit
cdb39e7c90
@ -11,7 +11,7 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import { escapeRegularExpression } from '@/utils/helpers/string';
|
import _ from 'lodash';
|
||||||
|
|
||||||
// Get the argument passed (e.g., "all-users-fr")
|
// Get the argument passed (e.g., "all-users-fr")
|
||||||
const arg: string | undefined = process.argv[2];
|
const arg: string | undefined = process.argv[2];
|
||||||
@ -27,8 +27,7 @@ const templatePath: string = path.join(__dirname, '../config/template.ts');
|
|||||||
|
|
||||||
// Check if a migration with the same name (excluding timestamp) already exists
|
// Check if a migration with the same name (excluding timestamp) already exists
|
||||||
const migrationExists: boolean = fs.readdirSync(migrationsDir).some((file) => {
|
const migrationExists: boolean = fs.readdirSync(migrationsDir).some((file) => {
|
||||||
const escapedRegExp = escapeRegularExpression(arg);
|
const regex = new RegExp(`^[0-9]+-${_.escapeRegExp(arg)}\.ts$`);
|
||||||
const regex = new RegExp(`^[0-9]+-${escapedRegExp}\.ts$`);
|
|
||||||
return regex.test(file);
|
return regex.test(file);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
7
api/package-lock.json
generated
7
api/package-lock.json
generated
@ -67,6 +67,7 @@
|
|||||||
"@types/express": "^4.17.17",
|
"@types/express": "^4.17.17",
|
||||||
"@types/express-session": "^1.17.10",
|
"@types/express-session": "^1.17.10",
|
||||||
"@types/jest": "^29.5.2",
|
"@types/jest": "^29.5.2",
|
||||||
|
"@types/lodash": "^4.17.9",
|
||||||
"@types/minio": "^7.1.1",
|
"@types/minio": "^7.1.1",
|
||||||
"@types/module-alias": "^2.0.4",
|
"@types/module-alias": "^2.0.4",
|
||||||
"@types/multer": "^1.4.11",
|
"@types/multer": "^1.4.11",
|
||||||
@ -6027,6 +6028,12 @@
|
|||||||
"@types/node": "*"
|
"@types/node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/lodash": {
|
||||||
|
"version": "4.17.9",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.9.tgz",
|
||||||
|
"integrity": "sha512-w9iWudx1XWOHW5lQRS9iKpK/XuRhnN+0T7HvdCCd802FYkT1AMTnxndJHGrNJwRoRHkslGr4S29tjm1cT7x/7w==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"node_modules/@types/mime": {
|
"node_modules/@types/mime": {
|
||||||
"version": "1.3.5",
|
"version": "1.3.5",
|
||||||
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.5.tgz",
|
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.5.tgz",
|
||||||
|
@ -91,6 +91,7 @@
|
|||||||
"@types/express": "^4.17.17",
|
"@types/express": "^4.17.17",
|
||||||
"@types/express-session": "^1.17.10",
|
"@types/express-session": "^1.17.10",
|
||||||
"@types/jest": "^29.5.2",
|
"@types/jest": "^29.5.2",
|
||||||
|
"@types/lodash": "^4.17.9",
|
||||||
"@types/module-alias": "^2.0.4",
|
"@types/module-alias": "^2.0.4",
|
||||||
"@types/multer": "^1.4.11",
|
"@types/multer": "^1.4.11",
|
||||||
"@types/node": "^20.3.1",
|
"@types/node": "^20.3.1",
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright © 2024 Hexastack. All rights reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
|
||||||
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
|
||||||
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
|
||||||
* 3. SaaS Restriction: This software, or any derivative of it, may not be used to offer a competing product or service (SaaS) without prior written consent from Hexastack. Offering the software as a service or using it in a commercial cloud environment without express permission is strictly prohibited.
|
|
||||||
*/
|
|
||||||
|
|
||||||
const reRegExpSpecialChars = /[\\^$.*+?()[\]{}|]/g,
|
|
||||||
reHasRegularExpressionChar = RegExp(reRegExpSpecialChars.source);
|
|
||||||
|
|
||||||
export const escapeRegularExpression = (string: string) =>
|
|
||||||
string && reHasRegularExpressionChar.test(string)
|
|
||||||
? string.replace(reRegExpSpecialChars, '\\$&')
|
|
||||||
: string;
|
|
@ -13,9 +13,9 @@ import {
|
|||||||
ArgumentMetadata,
|
ArgumentMetadata,
|
||||||
Logger,
|
Logger,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
|
import _ from 'lodash';
|
||||||
import { TFilterQuery, Types } from 'mongoose';
|
import { TFilterQuery, Types } from 'mongoose';
|
||||||
|
|
||||||
import { escapeRegularExpression } from '../helpers/string';
|
|
||||||
import {
|
import {
|
||||||
TFilterNestedKeysOfType,
|
TFilterNestedKeysOfType,
|
||||||
TSearchFilterValue,
|
TSearchFilterValue,
|
||||||
@ -37,7 +37,7 @@ export class SearchFilterPipe<T>
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getRegexValue(val: string) {
|
private getRegexValue(val: string) {
|
||||||
const escapedRegExp = escapeRegularExpression(val);
|
const escapedRegExp = _.escapeRegExp(val);
|
||||||
return new RegExp(escapedRegExp, 'i');
|
return new RegExp(escapedRegExp, 'i');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user