fix: properly handle character sets in globs (#24371)

https://github.com/microsoft/playwright/issues/24316
This commit is contained in:
Andrey Lushnikov 2023-07-24 20:49:05 +04:00 committed by GitHub
parent b4c412eb1f
commit fee08a6d3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -51,6 +51,12 @@ export function globToRegex(glob: string): RegExp {
case '?':
tokens.push('.');
break;
case '[':
tokens.push('[');
break;
case ']':
tokens.push(']');
break;
case '{':
inGroup = true;
tokens.push('(');

View File

@ -91,12 +91,14 @@ it('should work with glob', async () => {
expect(globToRegex('http://localhost:3000/signin-oidc*').test('http://localhost:3000/signin-oidc/foo')).toBeFalsy();
expect(globToRegex('http://localhost:3000/signin-oidc*').test('http://localhost:3000/signin-oidcnice')).toBeTruthy();
expect(globToRegex('**/three-columns/settings.html?**id=[a-z]**').test('http://mydomain:8080/blah/blah/three-columns/settings.html?id=settings-e3c58efe-02e9-44b0-97ac-dd138100cf7c&blah')).toBeTruthy();
expect(globToRegex('\\?')).toEqual(/^\?$/);
expect(globToRegex('\\')).toEqual(/^\\$/);
expect(globToRegex('\\\\')).toEqual(/^\\$/);
expect(globToRegex('\\[')).toEqual(/^\[$/);
expect(globToRegex('[')).toEqual(/^\[$/);
expect(globToRegex('$^+.\\*()|\\?\\{\\}[]')).toEqual(/^\$\^\+\.\*\(\)\|\?\{\}\[\]$/);
expect(globToRegex('[a-z]')).toEqual(/^[a-z]$/);
expect(globToRegex('$^+.\\*()|\\?\\{\\}\\[\\]')).toEqual(/^\$\^\+\.\*\(\)\|\?\{\}\[\]$/);
});
it('should intercept network activity from worker', async function({ page, server, isAndroid, browserName, browserMajorVersion }) {