Skip to content

Comments

fix: auto-prepend http:// to bare remote server URLs#175

Open
jfversluis wants to merge 1 commit intomainfrom
fix/remote-url-normalization
Open

fix: auto-prepend http:// to bare remote server URLs#175
jfversluis wants to merge 1 commit intomainfrom
fix/remote-url-normalization

Conversation

@jfversluis
Copy link
Collaborator

Problem

When entering a plain IP address like 192.168.1.5:4322 in the Remote URL field (without http://), PolyPilot can't connect. The URL was passed through without a scheme, and the fallback in InitializeRemoteAsync defaulted to wss:// which fails for plain LAN connections.

Fix

Added ConnectionSettings.NormalizeRemoteUrl() — a static helper that ensures the URL always has a proper scheme:

Input Output
192.168.1.5:4322 http://192.168.1.5:4322
localhost:4322 http://localhost:4322
xxx.devtunnels.ms https://xxx.devtunnels.ms
abc.ngrok.io https://abc.ngrok.io
http://already-valid.com http://already-valid.com (unchanged)

Applied at three entry points:

  1. Dashboard mobile connect (DashboardConnect)
  2. Settings page (SaveAndApply)
  3. CopilotService.Bridge (InitializeRemoteAsync) — which then converts http→ws, https→wss

Tests

13 new test cases in ConnectionSettingsTests.cs covering null/empty, existing schemes, bare IPs, known TLS hosts, whitespace/slash trimming, and double-scheme prevention.

All 1139 existing tests continue to pass (2 pre-existing failures unrelated to this change).

When users enter a plain IP like 192.168.1.5:4322 without a scheme,
the remote connection fails because the URL parser can't resolve it.

Add ConnectionSettings.NormalizeRemoteUrl() that:
- Passes through URLs that already have http/https/ws/wss scheme
- Detects devtunnels/ngrok/cloudflare hosts and uses https://
- Uses http:// for bare IPs, localhost, and LAN hostnames
- Trims whitespace and trailing slashes

Applied at Dashboard mobile connect, Settings SaveAndApply, and
InitializeRemoteAsync (which converts http→ws, https→wss).

Includes 13 new test cases covering all normalization paths.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

1 participant