Support linkify-ing urls
Summary: Changelog: The new logs plugin will linkify urls and pretty print json-like messages This implements one of our top papercuts (see linked task), and the WP request over here: https://fb.workplace.com/groups/flipperfyi/permalink/902949260471370/. Partially addresses https://github.com/facebook/flipper/issues/1162 https://github.com/facebook/flipper/issues/1010 https://github.com/facebook/flipper/issues/2029 Reviewed By: nikoant Differential Revision: D26947007 fbshipit-source-id: be0fdb476765905ae6b63bd8799c9c6093014de3
This commit is contained in:
committed by
Facebook GitHub Bot
parent
66774c90c6
commit
d73f6578a7
16
desktop/flipper-plugin/src/utils/safeStringify.tsx
Normal file
16
desktop/flipper-plugin/src/utils/safeStringify.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
export function safeStringify(value: any) {
|
||||
try {
|
||||
return JSON.stringify(value, null, 2);
|
||||
} catch (e) {
|
||||
return '<Failed to serialize: ' + e + '>';
|
||||
}
|
||||
}
|
||||
12
desktop/flipper-plugin/src/utils/urlRegex.tsx
Normal file
12
desktop/flipper-plugin/src/utils/urlRegex.tsx
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
// Source: https://github.com/sindresorhus/linkify-urls/blob/e0cf2a2d51dc8f5f95d93f97ecb1cc804cc9e6be/index.js#L5
|
||||
// n.b. no /g flag, as that makes the regex stateful! Which is not needed for splitting
|
||||
export const urlRegex = /((?<!\+)(?:https?(?::\/\/))(?:www\.)?(?:[a-zA-Z\d-_.]+(?:(?:\.|@)[a-zA-Z\d]{2,})|localhost)(?:(?:[-a-zA-Z\d:%_+.~#*$!?&//=@]*)(?:[,](?![\s]))*)*)/;
|
||||
Reference in New Issue
Block a user