mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-03 02:21:05 +08:00
- InspectorBackendCommands is now loaded via ES Modules Bug: 1006759 Change-Id: I2826518a55e1f4fd7704cfb04120885f9aa9b604 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1837772 Reviewed-by: Yang Guo <yangguo@chromium.org> Reviewed-by: Benedikt Meurer <bmeurer@chromium.org> Commit-Queue: Tim Van der Lippe <tvanderlippe@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#702821} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 01369246df2350c6be2b0118d69313a7f56486bb
54 lines
1.4 KiB
JavaScript
54 lines
1.4 KiB
JavaScript
// Copyright 2018 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
export default class NodeURL {
|
|
/**
|
|
* @param {!Object} object
|
|
*/
|
|
static patch(object) {
|
|
process(object, '');
|
|
|
|
/**
|
|
* @param {!Object} object
|
|
* @param {string} path
|
|
*/
|
|
function process(object, path) {
|
|
if (object.url && NodeURL._isPlatformPath(object.url, Host.isWin())) {
|
|
object.url = Common.ParsedURL.platformPathToURL(object.url);
|
|
}
|
|
for (const entry of Object.entries(object)) {
|
|
const key = entry[0];
|
|
const value = entry[1];
|
|
const entryPath = path + '.' + key;
|
|
if (entryPath !== '.result.result.value' && value !== null && typeof value === 'object') {
|
|
process(value, entryPath);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param {string} fileSystemPath
|
|
* @param {boolean} isWindows
|
|
* @return {boolean}
|
|
*/
|
|
static _isPlatformPath(fileSystemPath, isWindows) {
|
|
if (isWindows) {
|
|
const re = /^([a-z]:[\/\\]|\\\\)/i;
|
|
return re.test(fileSystemPath);
|
|
} else {
|
|
return fileSystemPath.length ? fileSystemPath[0] === '/' : false;
|
|
}
|
|
}
|
|
}
|
|
|
|
/* Legacy exported object */
|
|
self.Protocol = self.Protocol || {};
|
|
|
|
/* Legacy exported object */
|
|
Protocol = Protocol || {};
|
|
|
|
/** @constructor */
|
|
Protocol.NodeURL = NodeURL;
|