Files
Alex Rudenko 7d5f7dec09 fix: treat 0.0.0.0 and [::] browser endpoints as local (#3321)
`isLocalBrowser()` in `ToolHandler` uses `isLocalhost()` to decide if a
connected browser runs on the local machine. `isLocalhost()` does not
accept the unspecified addresses `0.0.0.0` and `[::]`. A connection to
these addresses reaches the local machine. Thus, `--browserUrl
http://0.0.0.0:9222` caused the tool handler to classify a local browser
as remote.

## Changes

- `src/utils/url.ts`: add `isLocalBrowserEndpoint()`. It accepts all
`isLocalhost()` hosts and the unspecified addresses `0.0.0.0`, `[::]`
and `[::ffff:0:0]`. `URL` normalizes `0`, `0x0`, `0.0`, `0.0.0.0.` and
`[::0]` to these forms.
- `src/ToolHandler.ts`: `isLocalBrowser()` uses
`isLocalBrowserEndpoint()`.
- `isLocalhost()` does not change. The telemetry `is_localhost` value
for page URLs does not change.

## Behavior changes

For a browser that is connected through a `0.0.0.0` or `[::]` endpoint,
these tools now run the local file path checks for local browsers:

- `upload_file` (`filePaths`)
- `install_pwa` (`installUrlOrBundleUrl`)
- `install_extension` (`path`)

Before this change, these tools skipped the checks for such endpoints.

## Tests

- `tests/utils/url.test.ts`: unit tests for `isLocalBrowserEndpoint()`.
- `tests/ToolHandler.test.ts`: a local-only `verifyFilesSchema` runs
`validatePath` for a `ws://0.0.0.0` endpoint. This test fails on `main`.
2026-10-22 12:43:42 +00:00
..