fix(config): accept S regex flag, anchor slashes
This commit is contained in:
parent
eff5f648a8
commit
2812254ba5
|
@ -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',
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue