mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-11-02 19:29:10 +08:00
Bug: chromium:1158760 Change-Id: I0804dbae263f41de3872c081a11750a9fde02f1e Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2826297 Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org> Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org> Auto-Submit: Jan Scheffler <janscheffler@chromium.org>
47 lines
1.3 KiB
TypeScript
47 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.
|
|
|
|
/* eslint-disable rulesdir/no_underscored_properties */
|
|
|
|
import * as Common from '../common/common.js';
|
|
import * as Host from '../host/host.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.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 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;
|
|
}
|
|
}
|