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:
shinpei_kim
2020-04-20 02:50:23 -07:00
committed by Facebook GitHub Bot
parent 21b79af5f2
commit ad6da949f7
10 changed files with 12 additions and 17 deletions

View File

@@ -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;

View File

@@ -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

View File

@@ -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');
}

View File

@@ -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);