MCPcopy Create free account
hub / github.com/Effect-TS/effect / splitPath

Function splitPath

packages/effect/src/encoding/Tar.ts:898–906  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

896
897// Split at the last slash that fits the 155-byte USTAR prefix.
898const splitPath = (path: string): readonly [prefix: string, name: string] | undefined => {
899 if (path.length <= 100 || !isAscii(path)) return undefined
900 let length = path.length
901 if (length > 156) length = 156
902 else if (path[length - 1] === "/") length--
903 const i = path.lastIndexOf("/", length - 1)
904 if (i <= 0 || path.length - i - 1 > 100) return undefined
905 return [path.slice(0, i), path.slice(i + 1)]
906}
907
908interface UstarFields {
909 readonly name: string

Callers 1

encodeHeaderFunction · 0.85

Calls 2

sliceMethod · 0.80
isAsciiFunction · 0.70

Tested by

no test coverage detected