Files
cypress/packages/server/lib/cloud/strip_path.ts
T
Ryan Manuel 38f980e0c4 internal: (studio) improve error reporting (#31546)
* internal: (studio) improvements to how studio can access the protocol database

* fix

* fix build

* refactor due to downstream changes

* feat: capture errors with studio

* types

* add tests

* fix types

* fix typescript

* strip path

* fix tests
2025-04-23 15:54:30 -05:00

15 lines
391 B
TypeScript

import { last } from 'lodash'
// strip everything but the file name to remove any sensitive
// data in the path
const pathRe = /'?((\/|\\+|[a-z]:\\)[^\s']+)+'?/ig
const pathSepRe = /[\/\\]+/
export const stripPath = (text: string) => {
return (text || '').replace(pathRe, (path) => {
const fileName = last(path.split(pathSepRe)) || ''
return `<stripped-path>${fileName}`
})
}