mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-08 12:53:45 +08:00
We failed to abstract away the types with capabilities, so I am bringing the type back in preparation of removing service/shadow workers shadow page target. Bug: 882467 Change-Id: I480bb18b1cfa9cf79e83435d735d102711991562 Reviewed-on: https://chromium-review.googlesource.com/c/1310759 Reviewed-by: Joel Einbinder <einbinder@chromium.org> Commit-Queue: Dmitry Gozman <dgozman@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#604446} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 1382cbcc0e916f8449d471dd54ca62aeb14db252
43 lines
1.2 KiB
JavaScript
43 lines
1.2 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.
|
|
|
|
Protocol.NodeURL = class {
|
|
/**
|
|
* @param {!Object} object
|
|
*/
|
|
static patch(object) {
|
|
process(object, '');
|
|
|
|
/**
|
|
* @param {!Object} object
|
|
* @param {string} path
|
|
*/
|
|
function process(object, path) {
|
|
if (object.url && Protocol.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;
|
|
}
|
|
}
|
|
};
|