Path: blob/main/extensions/copilot/src/util/common/pathRedaction.ts
13397 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45/**6* Redacts all things that look like a file path from a given input string.7*/8export function redactPaths(input: string): string {9return input10.replace(/([\s|(]|file:\/\/)(\/[^\s]+)/g, '$1[redacted]') // unix path11.replace(/([\s|(]|file:\/\/)([a-zA-Z]:[(\\|/){1,2}][^\s]+)/gi, '$1[redacted]') // windows path12.replace(/([\s|(]|file:\/\/)(\\[^\s]+)/gi, '$1[redacted]'); // unc path13}141516