Skip to content

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

Open
jfversluis wants to merge 2 commits intomainfrom
fix/remote-url-normalization
Open

fix: auto-prepend http:// to bare remote server URLs#175
jfversluis wants to merge 2 commits 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).

jfversluis and others added 2 commits February 25, 2026 19:01
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>
…scheme

- Replace .Contains('.ngrok') / .Contains('.cloudflare') with .EndsWith()
  on specific tunnel domains (.ngrok.io, .ngrok-free.app, .ngrok.app,
  .trycloudflare.com, .devtunnels.ms) to prevent false-positive HTTPS
  for hostnames that merely contain those substrings
- Replace explicit scheme prefix checks with a single trimmed.Contains('://')
  guard that passes through ANY scheme unchanged, preventing double-scheme
  malformation like http://ftp://host

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@PureWeen PureWeen force-pushed the fix/remote-url-normalization branch from 66710ee to a737284 Compare February 26, 2026 01:03
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.

2 participants