1
0
Fork 0

fix(config): accept S regex flag, anchor slashes

This commit is contained in:
ssube 2019-11-13 07:50:56 -06:00
parent eff5f648a8
commit 2812254ba5
Signed by: ssube
GPG Key ID: 3EED7B957D362AF1
2 changed files with 9 additions and 1 deletions

View File

@ -3,7 +3,7 @@ import { isNil } from 'lodash';
import { InvalidArgumentError } from '../../error/InvalidArgumentError';
export const REGEXP_REGEXP = /\/(.*)\/([gimuy]*)/;
export const REGEXP_REGEXP = /^\/(.+)\/([gimsuy]*)$/;
export const regexpType = new YamlType('!regexp', {
kind: 'scalar',

View File

@ -16,4 +16,12 @@ describeLeaks('regexp config type', async () => {
itLeaks('should not match bare strings', async () => {
expect(regexpType.resolve('foo')).to.equal(false);
});
itLeaks('should not match invalid flags', async () => {
expect(regexpType.resolve('/foo/notrealflags')).to.equal(false);
});
itLeaks('should not match regex embedded in a longer string', async () => {
expect(regexpType.resolve('some/regex/with-padding')).to.equal(false);
});
});