Skip to content

Commit

Permalink
fix(server): Update context find logic in context-registry
Browse files Browse the repository at this point in the history
  • Loading branch information
dethell committed Jun 7, 2024
1 parent c67eefe commit 33ccdbf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/wet-pumas-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"counterfact": patch
---

Update context-registry find logic for bug with mixed path casing
15 changes: 14 additions & 1 deletion src/server/context-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,26 @@ export class ContextRegistry {
this.add("/", {});
}

private getContextIgnoreCase(map: Map<string, Context>, key: string) {
const lowerCaseKey = key.toLowerCase();
for (const currentKey of map.keys()) {
if (currentKey.toLowerCase() === lowerCaseKey) {
return map.get(currentKey);
}
}
return undefined;
}

public add(path: string, context: Context): void {
this.entries.set(path, context);
this.cache.set(path, structuredClone(context));
}

public find(path: string): Context {
return this.entries.get(path) ?? this.find(parentPath(path));
return (
this.getContextIgnoreCase(this.entries, path) ??
this.find(parentPath(path))
);
}

// eslint-disable-next-line max-statements
Expand Down

0 comments on commit 33ccdbf

Please sign in to comment.