🎨 Be explicit in parsing regexp match result

This commit is contained in:
C-3PO 2018-11-04 16:59:18 +01:00
parent cdf4fbe117
commit 384fee4112
Signed by: c3po
GPG key ID: 62993C4BB4D86F24

View file

@ -5,7 +5,7 @@ export default function parseSpecEntry({ outputArgs, requiredOptions, shortToLon
if (longOption === '') { if (longOption === '') {
throw new Error(`The long option may not be an empty string. This is a bug in the source code of the script that you tried to call.`); throw new Error(`The long option may not be an empty string. This is a bug in the source code of the script that you tried to call.`);
} }
if (!longOption.match(/^[a-z0-9]+(-[a-z0-9]+)*$/)) { if (longOption.match(/^[a-z0-9]+(?:-[a-z0-9]+)*$/) === null) {
throw new Error(`The long option "${longOption}" must only contain alpha-numeric characters, optionally separated by hyphens. This is a bug in the source code of the script that you tried to call.`); throw new Error(`The long option "${longOption}" must only contain alpha-numeric characters, optionally separated by hyphens. This is a bug in the source code of the script that you tried to call.`);
} }