fix cloneObject() function to respect RegExp (#3240)

fixes #3237
This commit is contained in:
Karsten Hassel
2023-10-19 22:31:02 +02:00
committed by GitHub
parent a0b444d6c4
commit 0e2da630d5
3 changed files with 12 additions and 0 deletions

View File

@@ -90,6 +90,10 @@ function cloneObject(obj) {
return obj;
}
if (obj.constructor.name === "RegExp") {
return new RegExp(obj);
}
const temp = obj.constructor(); // give temp the original obj's constructor
for (const key in obj) {
temp[key] = cloneObject(obj[key]);