Moved mongo id validation into its own function
This commit is contained in:
parent
cabd17d2c9
commit
22b661ac49
@ -1141,7 +1141,7 @@ export class InventoryHelper {
|
|||||||
|
|
||||||
public validateInventoryUsesMonogoIds(itemsToValidate: Item[]) {
|
public validateInventoryUsesMonogoIds(itemsToValidate: Item[]) {
|
||||||
for (const item of itemsToValidate) {
|
for (const item of itemsToValidate) {
|
||||||
if (!/^[a-fA-F0-9]{24}$/.test(item._id)) {
|
if (!this.hashUtil.isValidMongoId(item._id)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`This profile is not compatible with 3.10.0, It contains an item with the ID: ${item._id} that is not compatible. Loading of SPT has been halted, use another profile or create a new one.`,
|
`This profile is not compatible with 3.10.0, It contains an item with the ID: ${item._id} that is not compatible. Loading of SPT has been halted, use another profile or create a new one.`,
|
||||||
);
|
);
|
||||||
|
@ -17,6 +17,15 @@ export class HashUtil {
|
|||||||
return mongoid();
|
return mongoid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* is the passed in string a valid mongo id
|
||||||
|
* @param stringToCheck String to check
|
||||||
|
* @returns True when string is a valid mongo id
|
||||||
|
*/
|
||||||
|
public isValidMongoId(stringToCheck: string) {
|
||||||
|
return /^[a-fA-F0-9]{24}$/.test(stringToCheck);
|
||||||
|
}
|
||||||
|
|
||||||
public generateMd5ForData(data: string): string {
|
public generateMd5ForData(data: string): string {
|
||||||
return this.generateHashForData("md5", data);
|
return this.generateHashForData("md5", data);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user