This repository has been archived on 2026-03-06. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
openclaw-extensions/wecom/node_modules/env-var/lib/accessors/regexp.js
T

22 lines
588 B
JavaScript

'use strict'
module.exports = function asRegExp (value, flags) {
// We have to test the value and flags indivudally if we want to write our
// own error messages,as there is no way to differentiate between the two
// errors except by using string comparisons.
// Test the flags
try {
RegExp(undefined, flags)
} catch (err) {
throw new Error('invalid regexp flags')
}
try {
return new RegExp(value, flags)
} catch (err) {
// We know that the regexp is the issue because we tested the flags earlier
throw new Error('should be a valid regexp')
}
}