MCPcopy Create free account
hub / github.com/ProtonDriveApps/sdk / scrubPathsInString

Function scrubPathsInString

cli/src/telemetry/sentry.ts:101–109  ·  view source on GitHub ↗

* Redacts path-like spans (and full http(s)/file URLs) so directory layout and user home are not sent.

(str: string)

Source from the content-addressed store, hash-verified

99 }
100 }
101}
102
103/**
104 * Redacts path-like spans (and full http(s)/file URLs) so directory layout and user home are not sent.
105 */
106function scrubPathsInString(str: string): string {
107 const unixPathRe = new RegExp(String.raw`(?<!:)(/(?:[^/\s]+/)*[^/\s]+(?::\d+){0,2})`, 'g');
108 return str
109 .replace(/\bfile:\/\/\S+/gi, PATH_REDACT)
110 .replace(/\bhttps?:\/\/\S+/gi, URL_REDACT)
111 .replace(/\\{2}[^\s'")\]]+/g, PATH_REDACT)
112 .replace(/\b[a-zA-Z]:\\[^\s'")\]]+/g, PATH_REDACT)

Callers 2

scrubStackFrameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected