fix(android): use isRegExp for a more robust check in different execution contexts (#11359)
This commit is contained in:
parent
5751a1255b
commit
a70f4e6410
|
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import { isString } from '../utils/utils';
|
import { isString, isRegExp } from '../utils/utils';
|
||||||
import * as channels from '../protocol/channels';
|
import * as channels from '../protocol/channels';
|
||||||
import { Events } from './events';
|
import { Events } from './events';
|
||||||
import { BrowserContext, prepareBrowserContextParams } from './browserContext';
|
import { BrowserContext, prepareBrowserContextParams } from './browserContext';
|
||||||
|
|
@ -289,7 +289,7 @@ function toSelectorChannel(selector: api.AndroidSelector): channels.AndroidSelec
|
||||||
const toRegex = (value: RegExp | string | undefined): string | undefined => {
|
const toRegex = (value: RegExp | string | undefined): string | undefined => {
|
||||||
if (value === undefined)
|
if (value === undefined)
|
||||||
return undefined;
|
return undefined;
|
||||||
if (value instanceof RegExp)
|
if (isRegExp(value))
|
||||||
return value.source;
|
return value.source;
|
||||||
return '^' + value.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d') + '$';
|
return '^' + value.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d') + '$';
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue