MCPcopy
hub / github.com/QwikDev/qwik / normalizePathSlash

Function normalizePathSlash

packages/qwik-city/src/utils/fs.ts:75–90  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

73}
74
75export function normalizePathSlash(path: string) {
76 // MIT https://github.com/sindresorhus/slash/blob/main/license
77 // Convert Windows backslash paths to slash paths: foo\\bar ➔ foo/bar
78 const isExtendedLengthPath = /^\\\\\?\\/.test(path);
79 const hasNonAscii = /[^\u0000-\u0080]+/.test(path); // eslint-disable-line no-control-regex
80
81 if (isExtendedLengthPath || hasNonAscii) {
82 return path;
83 }
84
85 path = path.replace(/\\/g, '/');
86 if (path.endsWith('/')) {
87 path = path.slice(0, path.length - 1);
88 }
89 return path;
90}
91
92/**
93 * Creates an id for the module, based on its path.

Callers 2

generateFunction · 0.90
normalizePathFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…