mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-16 22:21:51 +00:00
Fix crash from passing an invalid regex source to TRegex validation function
This commit is contained in:
parent
c03e7240b4
commit
a558af1038
1 changed files with 9 additions and 1 deletions
|
@ -27,7 +27,15 @@ export const TRegex = new t.Type<RegExp, string>(
|
||||||
(s): s is RegExp => s instanceof RegExp,
|
(s): s is RegExp => s instanceof RegExp,
|
||||||
(from, to) =>
|
(from, to) =>
|
||||||
either.chain(t.string.validate(from, to), s => {
|
either.chain(t.string.validate(from, to), s => {
|
||||||
return t.success(inputPatternToRegExp(s));
|
try {
|
||||||
|
return t.success(inputPatternToRegExp(s));
|
||||||
|
} catch (err) {
|
||||||
|
if (err instanceof InvalidRegexError) {
|
||||||
|
return t.failure(s, [], err.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
s => `/${s.source}/${s.flags}`,
|
s => `/${s.source}/${s.flags}`,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue