Skip to content

Commit f74d0e7

Browse files
committed
chore: remove dead code and tighten defaults
- Remove unused escapeHtml (codebase uses textContent throughout) - Change retryWithStrategy default retryOn from [401,429] to [429] (all call sites already override this; 401 should not be retried) - Remove keys field from LRUCache.getStats() (only size/utilization used)
1 parent a82cf33 commit f74d0e7

5 files changed

Lines changed: 1 addition & 43 deletions

File tree

src/lib/format-utils.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,20 +81,6 @@ export function getNotificationStatus(notif) {
8181
return type;
8282
}
8383

84-
/**
85-
* Escape HTML to prevent XSS
86-
* Uses string replacement instead of DOM manipulation for better performance
87-
*/
88-
export function escapeHtml(text) {
89-
if (text === null || text === undefined) return "";
90-
return String(text)
91-
.replace(/&/g, "&")
92-
.replace(/</g, "&lt;")
93-
.replace(/>/g, "&gt;")
94-
.replace(/"/g, "&quot;")
95-
.replace(/'/g, "&#39;");
96-
}
97-
9884
/**
9985
* Classify a network/API error into a category for consistent handling
10086
* @param {Error} error - Error object

src/lib/github-api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ async function retryWithStrategy(fetchFn, options = {}) {
7070
maxRetries = 3,
7171
baseDelay = API_TIMEOUTS.RETRY_BASE_DELAY,
7272
backoff = "exponential",
73-
retryOn = [401, 429],
73+
retryOn = [429],
7474
checkResponse = true,
7575
} = options;
7676

src/lib/lru-cache.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ export class LRUCache {
7979
size: this.cache.size,
8080
maxSize: this.maxSize,
8181
utilization: `${((this.cache.size / this.maxSize) * 100).toFixed(1)}%`,
82-
keys: Array.from(this.cache.keys()),
8382
};
8483
}
8584
}

tests/format-utils.test.js

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
formatType,
55
formatState,
66
getNotificationStatus,
7-
escapeHtml,
87
classifyError,
98
} from "../src/lib/format-utils.js";
109

@@ -115,31 +114,6 @@ describe("getNotificationStatus", () => {
115114
});
116115
});
117116

118-
describe("escapeHtml", () => {
119-
it("should escape HTML special characters", () => {
120-
expect(escapeHtml("<script>")).toBe("&lt;script&gt;");
121-
expect(escapeHtml("a & b")).toBe("a &amp; b");
122-
expect(escapeHtml('"quotes"')).toBe("&quot;quotes&quot;");
123-
expect(escapeHtml("'apostrophe'")).toBe("&#39;apostrophe&#39;");
124-
});
125-
126-
it("should handle combined special characters", () => {
127-
expect(escapeHtml('<a href="url">link</a>')).toBe(
128-
"&lt;a href=&quot;url&quot;&gt;link&lt;/a&gt;",
129-
);
130-
});
131-
132-
it("should handle null/undefined", () => {
133-
expect(escapeHtml(null)).toBe("");
134-
expect(escapeHtml(undefined)).toBe("");
135-
});
136-
137-
it("should convert non-string values to string", () => {
138-
expect(escapeHtml(123)).toBe("123");
139-
expect(escapeHtml(true)).toBe("true");
140-
});
141-
});
142-
143117
describe("classifyError", () => {
144118
it('should classify rate limit errors as "rate-limited"', () => {
145119
expect(classifyError(new Error("Rate limited until 12:00"))).toBe("rate-limited");

tests/lru-cache.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ describe("LRUCache", () => {
114114
expect(stats.size).toBe(2);
115115
expect(stats.maxSize).toBe(3);
116116
expect(stats.utilization).toBe("66.7%");
117-
expect(stats.keys).toEqual(["a", "b"]);
118117
});
119118

120119
it("should show 0% utilization when empty", () => {

0 commit comments

Comments
 (0)