Skip to content

Resolve fetch() URL constants in data source scanner#30

Merged
kurtstohrer merged 1 commit into
mainfrom
fix/issue-29-fetch-url-constants
Apr 21, 2026
Merged

Resolve fetch() URL constants in data source scanner#30
kurtstohrer merged 1 commit into
mainfrom
fix/issue-29-fetch-url-constants

Conversation

@kurtstohrer

Copy link
Copy Markdown
Owner

Summary

  • Fixes Data source scanner misses fetch() calls that use a URL constant #29 — the data-source scanner now detects fetch() calls whose URL argument is a named constant rather than a string literal.
  • Collects file-local const/let/var NAME = '<url-or-path>' declarations into a lookup table and resolves bare identifier first-arguments (e.g. fetch(LIST_URL, { signal })/api/items?…) before the legacy /api-path fallback runs.
  • Added a regression test covering both a relative-path constant (/api/items?…) and a full-URL constant (http://localhost:4320/api/items/42).

Test plan

  • pnpm vitest run src/server/__tests__/data-source-scanner.test.ts — 9/9 pass
  • pnpm vitest run — 223/223 pass

The inline-fetch scanner only extracted endpoints from string literals
and template literals, so `fetch(LIST_URL, …)` where LIST_URL was a
module-level const silently produced no entry. Collect URL/path string
constants alongside the existing base-URL table and resolve bare
identifier arguments against it before falling back to path matching.

Fixes #29
@kurtstohrer kurtstohrer merged commit 46dd756 into main Apr 21, 2026
3 of 4 checks passed
@kurtstohrer kurtstohrer deleted the fix/issue-29-fetch-url-constants branch April 21, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Data source scanner misses fetch() calls that use a URL constant

1 participant