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

Function dirname

packages/qwik/src/optimizer/src/path.ts:322–351  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

320 };
321
322 const dirname = function dirname(path: string) {
323 assertPath(path);
324 if (path.length === 0) {
325 return '.';
326 }
327 let code = path.charCodeAt(0);
328 const hasRoot = code === 47; /*/*/
329 let end = -1;
330 let matchedSlash = true;
331 for (let i = path.length - 1; i >= 1; --i) {
332 code = path.charCodeAt(i);
333 if (code === 47 /*/*/) {
334 if (!matchedSlash) {
335 end = i;
336 break;
337 }
338 } else {
339 // We saw the first non-path separator
340 matchedSlash = false;
341 }
342 }
343
344 if (end === -1) {
345 return hasRoot ? '/' : '.';
346 }
347 if (hasRoot && end === 1) {
348 return '//';
349 }
350 return path.slice(0, end);
351 };
352
353 const basename = function basename(path: string, ext: string) {
354 if (ext !== undefined && typeof ext !== 'string') {

Callers 15

qwik.unit.tsFile · 0.90
qwikloader.unit.tsFile · 0.90
preloader.unit.tsFile · 0.90
_computeWorkspaceRootFunction · 0.90
rootDirMethod · 0.85
commitFunction · 0.85
getMenuPathnameFunction · 0.85
createFileIdFunction · 0.85
ensureDirFunction · 0.85
generateFunction · 0.85
getParentDirFunction · 0.85

Calls 1

assertPathFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…