OCPP UI: remove wss assumption (#28996)

This commit is contained in:
Michael Geers 2026-06-07 12:56:28 +02:00 • committed by GitHub
parent 9e9a07221b
commit 0fa8b97daf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 9 deletions

View file

@ -59,8 +59,7 @@ func ExternalUrl() string {
return ""
}
// Replace protocol: http -> ws, https -> wss
u.Scheme = strings.Replace(u.Scheme, "http", "ws", 1)
u.Scheme = "ws"
u.Host = fmt.Sprintf("%s:%d", strings.Split(u.Host, ":")[0], 8887) // deliberately fixed, port configurability only for testing
return u.String()

View file

@ -16,15 +16,9 @@ func TestMain(m *testing.M) {
func TestExternalUrl(t *testing.T) {
tests := []struct{ input, expected string }{
{"", ""},
{"http://example.com:7070", "ws://example.com:8887"},
{"https://example.com:443", "wss://example.com:8887"},
{"http://example.com", "ws://example.com:8887"},
{"https://example.com", "wss://example.com:8887"},
{"https://example.com:443", "ws://example.com:8887"},
{"http://10.20.30.40:7070/path", "ws://10.20.30.40:8887/path"},
{"https://example.com/path", "wss://example.com:8887/path"},
{"ws://example.com", "ws://example.com:8887"},
{"wss://example.com:9000", "wss://example.com:8887"},
{"strange://example.com", "strange://example.com:8887"},
}
for _, tt := range tests {