MCPcopy Index your code
hub / github.com/codedogQBY/ReadAny / normalizeS3Key

Function normalizeS3Key

packages/core/src/sync/s3-paths.ts:20–31  ·  view source on GitHub ↗
(remoteRoot: string, path: string)

Source from the content-addressed store, hash-verified

18}
19
20export function normalizeS3Key(remoteRoot: string, path: string): string {
21 const root = sanitizeS3RemoteRoot(remoteRoot) || DEFAULT_S3_REMOTE_ROOT;
22 let normalized = stripControlChars(path).trim().replace(/^\/+/, "");
23 if (normalized === root || normalized.startsWith(`${root}/`)) {
24 return normalized;
25 }
26 normalized = normalized.replace(/^readany(?=\/|$)/, root);
27 if (normalized === root || normalized.startsWith(`${root}/`)) {
28 return normalized;
29 }
30 return `${root}/${normalized}`;
31}
32
33export function s3KeyToLogicalPath(remoteRoot: string, key: string): string {
34 const root = sanitizeS3RemoteRoot(remoteRoot) || DEFAULT_S3_REMOTE_ROOT;

Callers 2

normalizePathMethod · 0.90
s3-backend.test.tsFile · 0.90

Calls 3

sanitizeS3RemoteRootFunction · 0.85
replaceMethod · 0.80
stripControlCharsFunction · 0.70

Tested by

no test coverage detected