Validates a URL's syntax and tests whether the server is reachable.
Strategy:
HEAD → 2xx/3xx → reachable, no proxy needed.
HEAD → 4xx/5xx → server is alive but the bare path fails. Try OGC GetCapabilities
directly (CORS was fine since HEAD got a response). If valid → reachable. Otherwise → not reachable.
HEAD → CORS → server is alive but blocks cross-origin. Try OGC GetCapabilities
through the proxy. If valid → reachable + needsProxy. Otherwise → not reachable.
HEAD → network/timeout → server unreachable.
The function never throws — all failures are returned as part of the result object.
Parameters
targetUrl: string
The URL to validate and ping.
proxyBase: string = CONFIG_PROXY_URL
Optional. The proxy server base URL. Defaults to CONFIG_PROXY_URL.
timeoutMs: number = 5000
Optional. Request timeout in milliseconds. Defaults to 5000ms.
Returns Promise<PingResult>
A result object with isValid, isReachable, needsProxy, status, and optional error.
Validates a URL's syntax and tests whether the server is reachable.
Strategy:
The function never throws — all failures are returned as part of the result object.