MCPcopy
hub / github.com/vitejs/vite / encodePathChars

Function encodePathChars

packages/vite/src/module-runner/utils.ts:26–36  ·  view source on GitHub ↗
(filepath: string)

Source from the content-addressed store, hash-verified

24const hashRegex = /#/g
25
26function encodePathChars(filepath: string) {
27 if (filepath.includes('%')) filepath = filepath.replace(percentRegEx, '%25')
28 // In posix, backslash is a valid character in paths:
29 if (!isWindows && filepath.includes('\\'))
30 filepath = filepath.replace(backslashRegEx, '%5C')
31 if (filepath.includes('\n')) filepath = filepath.replace(newlineRegEx, '%0A')
32 if (filepath.includes('\r'))
33 filepath = filepath.replace(carriageReturnRegEx, '%0D')
34 if (filepath.includes('\t')) filepath = filepath.replace(tabRegEx, '%09')
35 return filepath
36}
37
38export const posixDirname: (path: string) => string = pathe.dirname
39export const posixResolve: (...paths: string[]) => string = pathe.resolve

Callers 1

posixPathToFileHrefFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected