geoview-core - v2.1.2
    Preparing search index...

    Function validateAndPingUrl

    • Validates a URL's syntax and tests whether the server is reachable.

      Strategy:

      1. HEAD → 2xx/3xx → reachable, no proxy needed.
      2. 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.
      3. HEAD → CORS → server is alive but blocks cross-origin. Try OGC GetCapabilities through the proxy. If valid → reachable + needsProxy. Otherwise → not reachable.
      4. 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.