* Redacts path-like spans (and full http(s)/file URLs) so directory layout and user home are not sent.
(str: string)
| 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 | */ |
| 106 | function 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) |
no outgoing calls
no test coverage detected