Skip to content

Commit 75030fd

Browse files
committed
fix(regex): throw on badly formatted regex
1 parent 3dc1541 commit 75030fd

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/config/shortstops.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,10 @@ export function shortstops(service: { name: string }, sourcedir: string) {
122122
},
123123
base64: base64Handler(),
124124
regex(v: string) {
125-
const [, pattern, flags] = v.match(/^\/(.*)\/([a-z]*)/) || [];
125+
const [, pattern, flags] = v.match(/^\/(.*)\/([a-z]*)$/) || [];
126+
if (pattern === undefined) {
127+
throw new Error(`Invalid regular expression in configuration ${v}`);
128+
}
126129
return new RegExp(pattern, flags);
127130
},
128131

0 commit comments

Comments
 (0)