MCPcopy
hub / github.com/fosrl/pangolin / oldKeyComputation

Function oldKeyComputation

server/lib/traefik/pathEncoding.test.ts:29–43  ·  view source on GitHub ↗

* Exact replica of the OLD key computation from upstream main. * Uses sanitize() for paths - this is what had the collision bug.

(
    resourceId: number,
    path: string | null,
    pathMatchType: string | null,
    rewritePath: string | null,
    rewritePathType: string | null
)

Source from the content-addressed store, hash-verified

27 * Uses sanitize() for paths - this is what had the collision bug.
28 */
29function oldKeyComputation(
30 resourceId: number,
31 path: string | null,
32 pathMatchType: string | null,
33 rewritePath: string | null,
34 rewritePathType: string | null
35): string {
36 const targetPath = sanitize(path) || "";
37 const pmt = pathMatchType || "";
38 const rp = rewritePath || "";
39 const rpt = rewritePathType || "";
40 const pathKey = [targetPath, pmt, rp, rpt].filter(Boolean).join("-");
41 const mapKey = [resourceId, pathKey].filter(Boolean).join("-");
42 return sanitize(mapKey) || "";
43}
44
45/**
46 * Replica of the NEW key computation from our fix.

Callers 1

runTestsFunction · 0.85

Calls 1

sanitizeFunction · 0.70

Tested by

no test coverage detected