Skip to content

Commit 4cc6366

Browse files
committed
Detection endpoint: path-based scheme /api/<domain>/detect
Swap ?domain= query for a RESTful path: GET /api/<domain>/detect. Leaves room for /api/<domain>/<action> as more per-domain operations land.
1 parent bc0b715 commit 4cc6366

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

worker/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ export default {
2727
const url = new URL(request.url);
2828

2929
// Detection endpoint: run the full agent-readiness battery for a domain.
30-
// GET /api/detect?domain=<domain> -> structured DetectionResult (cached 1h).
31-
if (url.pathname === "/api/detect") {
32-
const domain = cleanDomain(url.searchParams.get("domain"));
33-
if (!domain) return json({ error: "pass ?domain=<a valid domain>" }, 400);
34-
const cacheKey = new Request(`https://integrations.sh/api/detect?domain=${domain}`);
30+
// GET /api/<domain>/detect -> structured DetectionResult (cached 1h).
31+
const detectMatch = url.pathname.match(/^\/api\/([^/]+)\/detect\/?$/);
32+
if (detectMatch) {
33+
const domain = cleanDomain(decodeURIComponent(detectMatch[1]));
34+
if (!domain) return json({ error: "invalid domain — GET /api/<domain>/detect" }, 400);
35+
const cacheKey = new Request(`https://integrations.sh/api/${domain}/detect`);
3536
const cache = (caches as unknown as { default: Cache }).default;
3637
const cached = await cache.match(cacheKey);
3738
if (cached) return cached;

0 commit comments

Comments
 (0)