Simplify RegExp (#995)
Summary: ## Changelog Pull Request resolved: https://github.com/facebook/flipper/pull/995 Reviewed By: passy Differential Revision: D21112956 Pulled By: priteshrnandgaonkar fbshipit-source-id: 14d79dd399970c49835aab7eeb7dbd69ee323ab9
This commit is contained in:
committed by
Facebook GitHub Bot
parent
21b79af5f2
commit
ad6da949f7
@@ -335,8 +335,8 @@ const Searchable = (
|
||||
|
||||
matchTags = debounce((searchTerm: string, matchEnd: boolean) => {
|
||||
const filterPattern = matchEnd
|
||||
? /([a-z][a-z0-9]*[!]?[:=][^\s]+)($|\s)/gi
|
||||
: /([a-z][a-z0-9]*[!]?[:=][^\s]+)\s/gi;
|
||||
? /([a-z]\w*[!]?[:=]\S+)($|\s)/gi
|
||||
: /([a-z]\w*[!]?[:=]\S+)\s/gi;
|
||||
const match = searchTerm.match(filterPattern);
|
||||
if (match && match.length > 0) {
|
||||
match.forEach((filter: string) => {
|
||||
|
||||
@@ -46,7 +46,7 @@ const deviceClientCertFile = 'device.crt';
|
||||
const caSubject = '/C=US/ST=CA/L=Menlo Park/O=Sonar/CN=SonarCA';
|
||||
const serverSubject = '/C=US/ST=CA/L=Menlo Park/O=Sonar/CN=localhost';
|
||||
const minCertExpiryWindowSeconds = 24 * 60 * 60;
|
||||
const allowedAppNameRegex = /^[a-zA-Z0-9._\-]+$/;
|
||||
const allowedAppNameRegex = /^[\w._-]+$/;
|
||||
const logTag = 'CertificateProvider';
|
||||
/*
|
||||
* RFC2253 specifies the unamiguous x509 subject format.
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
import {UnsupportedError} from './metrics';
|
||||
import adbkit, {Client} from 'adbkit';
|
||||
|
||||
const allowedAppNameRegex = /^[a-zA-Z0-9._\-]+$/;
|
||||
const allowedAppNameRegex = /^[\w._-]+$/;
|
||||
const appNotApplicationRegex = /is not an application/;
|
||||
const appNotDebuggableRegex = /debuggable/;
|
||||
const operationNotPermittedRegex = /not permitted/;
|
||||
|
||||
@@ -16,7 +16,7 @@ export function parseFlipperPorts(
|
||||
// Malformed numbers will get parsed to NaN which is not > 0
|
||||
if (
|
||||
ports.length === 2 &&
|
||||
components.every((x) => /^[0-9]+$/.test(x)) &&
|
||||
components.every((x) => /^\d+$/.test(x)) &&
|
||||
ports.every((x) => x > 0)
|
||||
) {
|
||||
return {
|
||||
|
||||
@@ -15,7 +15,7 @@ const isFBFile = (filePath: string) =>
|
||||
filePath.includes(`${path.sep}fb${path.sep}`);
|
||||
|
||||
const requireFromFolder = (folder: string, path: string) =>
|
||||
new RegExp(folder + '/[A-Za-z0-9.-_]+(.js)?$', 'g').test(path);
|
||||
new RegExp(folder + '/[\\w.-_]+(.js)?$', 'g').test(path);
|
||||
|
||||
module.exports = () => ({
|
||||
name: 'replace-fb-stubs',
|
||||
|
||||
@@ -123,7 +123,7 @@ test(
|
||||
'Output includes fileVersion',
|
||||
() => {
|
||||
return runHeadless(basicArgs).then((result) => {
|
||||
expect(result.output.fileVersion).toMatch(/[0-9]+\.[0-9]+\.[0-9]+/);
|
||||
expect(result.output.fileVersion).toMatch(/\d+\.\d+\.\d+/);
|
||||
});
|
||||
},
|
||||
TEST_TIMEOUT_MS,
|
||||
|
||||
@@ -275,10 +275,10 @@ export function parseCrashLog(
|
||||
const fallbackReason = UNKNOWN_CRASH_REASON;
|
||||
switch (os) {
|
||||
case 'iOS': {
|
||||
const regex = /Exception Type: *[\w]*/;
|
||||
const regex = /Exception Type: *\w*/;
|
||||
const arr = regex.exec(content);
|
||||
const exceptionString = arr ? arr[0] : '';
|
||||
const exceptionRegex = /[\w]*$/;
|
||||
const exceptionRegex = /\w*$/;
|
||||
const tmp = exceptionRegex.exec(exceptionString);
|
||||
const exception = tmp && tmp[0].length ? tmp[0] : fallbackReason;
|
||||
|
||||
|
||||
@@ -12,10 +12,7 @@ import React from 'react';
|
||||
import electron from 'electron';
|
||||
|
||||
const devToolsNodeId = (url: string) =>
|
||||
`hermes-chromedevtools-out-of-react-node-${url.replace(
|
||||
/[^a-zA-Z0-9]+/g,
|
||||
'-',
|
||||
)}`;
|
||||
`hermes-chromedevtools-out-of-react-node-${url.replace(/\W+/g, '-')}`;
|
||||
|
||||
// TODO: build abstractionf or this: T62306732
|
||||
const TARGET_CONTAINER_ID = 'flipper-out-of-contents-container'; // should be a hook in the future
|
||||
|
||||
@@ -167,7 +167,7 @@ export default class KaiOSGraphs extends FlipperDevicePlugin<State, any, any> {
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
if (fields[1].match(/[^0-9]+/)) {
|
||||
if (fields[1].match(/\D+/)) {
|
||||
// TODO: probably implement this through something other than b2g
|
||||
throw new Error('Support for names with spaces is not implemented');
|
||||
}
|
||||
|
||||
@@ -12,9 +12,7 @@ import {colors, StackTrace} from 'flipper';
|
||||
|
||||
const FacebookLibraries = ['Facebook'];
|
||||
|
||||
const REGEX = new RegExp(
|
||||
'(?<library>[A-Za-z0-9]*) *(?<address>0x[A-Za-z0-9]*) (?<caller>(.*)) \\+ (?<lineNumber>[0-9]*)',
|
||||
);
|
||||
const REGEX = /(?<library>\w*) *(?<address>0x\w*) (?<caller>(.*)) \\+ (?<lineNumber>\d*)/;
|
||||
|
||||
function isSystemLibrary(libraryName: ?string): boolean {
|
||||
return !FacebookLibraries.includes(libraryName);
|
||||
|
||||
Reference in New Issue
Block a user