MCPcopy
hub / github.com/facebook/docusaurus / shortName

Function shortName

packages/docusaurus-utils/src/pathUtils.ts:29–46  ·  view source on GitHub ↗
(str: string)

Source from the content-addressed store, hash-verified

27 Buffer.from(str).length + SPACE_FOR_APPENDING > MAX_PATH_SEGMENT_BYTES;
28
29export function shortName(str: string): string {
30 if (isMacOs() || isWindows()) {
31 const overflowingChars = str.length - MAX_PATH_SEGMENT_CHARS;
32 return str.slice(
33 0,
34 str.length - overflowingChars - SPACE_FOR_APPENDING - 1,
35 );
36 }
37 const strBuffer = Buffer.from(str);
38 const overflowingBytes =
39 Buffer.byteLength(strBuffer) - MAX_PATH_SEGMENT_BYTES;
40 return strBuffer
41 .slice(
42 0,
43 Buffer.byteLength(strBuffer) - overflowingBytes - SPACE_FOR_APPENDING - 1,
44 )
45 .toString();
46}
47
48/**
49 * Convert Windows backslash paths to posix style paths.

Callers 2

docuHashFunction · 0.90
pathUtils.test.tsFile · 0.90

Calls 2

isMacOsFunction · 0.85
isWindowsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…