mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-07 04:26:32 +08:00
Bug: 1253323 Change-Id: I3e68f083971d47e90dbb1fcfb3798d283924a0c6 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3217628 Reviewed-by: Simon Zünd <szuend@chromium.org> Reviewed-by: Danil Somsikov <dsv@chromium.org> Reviewed-by: Eric Leese <leese@chromium.org> Commit-Queue: Kateryna Prokopenko <kprokopenko@chromium.org>
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
// 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.
|
|
|
|
import * as Common from '../common/common.js';
|
|
import * as Host from '../host/host.js';
|
|
import type * as Platform from '../platform/platform.js';
|
|
|
|
export class NodeURL {
|
|
static patch(object: {
|
|
url?: string,
|
|
}): void {
|
|
process(object, '');
|
|
|
|
function process(object: {url?: string}, path: string): void {
|
|
if (object.url && NodeURL.isPlatformPath(object.url, Host.Platform.isWin())) {
|
|
object.url = Common.ParsedURL.ParsedURL.rawPathToUrlString(object.url as Platform.DevToolsPath.RawPathString);
|
|
}
|
|
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 as {
|
|
url: string,
|
|
}),
|
|
entryPath);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
static isPlatformPath(fileSystemPath: string, isWindows: boolean): boolean {
|
|
if (isWindows) {
|
|
const re = /^([a-z]:[\/\\]|\\\\)/i;
|
|
return re.test(fileSystemPath);
|
|
}
|
|
return fileSystemPath.length ? fileSystemPath[0] === '/' : false;
|
|
}
|
|
}
|