Description
Drop dead code and make loopback detection consistent.
Problem Statement
src/network/index.ts:41 — const LOCAL_HOSTS = new Set(['localhost', '127.0.0.1', '[::1]', '::1']); is tested against parsed.hostname (line 72).
The WHATWG URL parser always returns IPv6 hostnames in bracketed form (new URL('http://[::1]:8000').hostname === '[::1]'), so the bare '::1' entry can never match and is dead.
The set also misses the rest of the loopback range (127.0.0.0/8, e.g. 127.0.0.2), so allowInsecureLocalhost behaves inconsistently for hosts a developer would reasonably consider local.
Proposed Changes
Technical Implementation Scaffolding
- Target Repository: vero-sdk
- Target Path: src/network/index.ts
- Branch Naming: fix/issue--loopback-host-detection
- Authority Context: Correctness — dead code and inconsistent local detection
Acceptance Criteria
Definition of Done
Description
Drop dead code and make loopback detection consistent.
Problem Statement
src/network/index.ts:41—const LOCAL_HOSTS = new Set(['localhost', '127.0.0.1', '[::1]', '::1']);is tested againstparsed.hostname(line 72).The WHATWG URL parser always returns IPv6 hostnames in bracketed form (
new URL('http://[::1]:8000').hostname === '[::1]'), so the bare'::1'entry can never match and is dead.The set also misses the rest of the loopback range (
127.0.0.0/8, e.g.127.0.0.2), soallowInsecureLocalhostbehaves inconsistently for hosts a developer would reasonably consider local.Proposed Changes
'::1'entry127.0.0.0/8,[::1], andlocalhosthttp://127.0.0.2:8000andhttp://[::1]:8000underallowInsecureLocalhostTechnical Implementation Scaffolding
Acceptance Criteria
validateUrl('http://[::1]:8000', { allowInsecureLocalhost: true })succeeds andvalidateUrl('http://[::1]:8000')throwsINVALID_URLhttp://127.0.0.2is treated consistently withhttp://127.0.0.1Definition of Done