MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / normalizePath

Function normalizePath

packages/core/src/utils/path.ts:151–169  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

149// posix version
150/** JSDoc */
151export function normalizePath(path: string): string {
152 const isPathAbsolute = isAbsolute(path);
153 const trailingSlash = path.slice(-1) === '/';
154
155 // Normalize the path
156 let normalizedPath = normalizeArray(
157 path.split('/').filter(p => !!p),
158 !isPathAbsolute,
159 ).join('/');
160
161 if (!normalizedPath && !isPathAbsolute) {
162 normalizedPath = '.';
163 }
164 if (normalizedPath && trailingSlash) {
165 normalizedPath += '/';
166 }
167
168 return (isPathAbsolute ? '/' : '') + normalizedPath;
169}
170
171// posix version
172/** JSDoc */

Callers 1

joinFunction · 0.70

Calls 3

isAbsoluteFunction · 0.85
normalizeArrayFunction · 0.85
sliceMethod · 0.80

Tested by

no test coverage detected