mirror of
https://github.com/jason5ng32/MyIP.git
synced 2026-11-04 08:55:47 +00:00
Five small quality-of-life fixes found during the backend review, each
independent of the others:
- api/cf-radar.js: drop unused `import { parse } from 'dotenv'`; hoist
`cleanUpResponseData` from inside the default export to module scope
so it's not re-created on every request.
- api/mac-checker.js: tighten `isValidMAC` to exactly 12 hex chars. The
previous 6–12 range was too permissive — partial MAC prefixes would
reach the upstream API and return garbage.
- common/referer-check.js: drop `dotenv.config()`. It already ran once
from backend-server.js via normal import order; duplicating on every
referer check was wasted work and muddied responsibilities
(referer-check shouldn't own env bootstrap).
- frontend/utils/valid-ip.js: re-export from common/valid-ip.js instead
of keeping a near-duplicate copy. tests/valid-ip.test.js already
asserts both paths agree, so the thin re-export keeps that test
passing while removing the drift risk.
The configs.js "req.method !== 'GET'" branch looked like dead code but
a dedicated smoke test asserts it, so it stays as defensive programming
in case the handler is ever mounted with app.all(). Not touched.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>