MCPcopy
hub / github.com/esm-dev/esm.sh / normalizeSavePath

Function normalizeSavePath

server/build_resolver.go:1370–1385  ·  view source on GitHub ↗
(pathname string)

Source from the content-addressed store, hash-verified

1368}
1369
1370func normalizeSavePath(pathname string) string {
1371 if strings.HasPrefix(pathname, "modules/transform/") || strings.HasPrefix(pathname, "modules/x/") {
1372 return pathname
1373 }
1374 segments := strings.Split(pathname, "/")
1375 for i, seg := range segments {
1376 if strings.HasPrefix(seg, "X-") && len(seg) > 42 {
1377 h := sha1.New()
1378 h.Write([]byte(seg))
1379 segments[i] = "x-" + hex.EncodeToString(h.Sum(nil))
1380 } else if strings.HasPrefix(seg, "*") {
1381 segments[i] = seg[1:] + "/ea"
1382 }
1383 }
1384 return strings.Join(segments, "/")
1385}
1386
1387// normalizeImportSpecifier normalizes the given specifier.
1388func normalizeImportSpecifier(specifier string) string {

Callers 4

esmRouterFunction · 0.85
legacyESMFunction · 0.85
getSavePathMethod · 0.85
transformDTSFunction · 0.85

Calls 1

WriteMethod · 0.80

Tested by

no test coverage detected