sync: migrate ai-operator to Gitea (2026-08-10)
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package asteriskws
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func BuildMediaWebSocketURL(baseURL, connectionID string) (string, string, error) {
|
||||
if strings.TrimSpace(connectionID) == "" {
|
||||
return "", "", errors.New("media websocket connection id is empty")
|
||||
}
|
||||
base := strings.TrimRight(baseURL, "/")
|
||||
parsed, err := url.Parse(base + "/" + url.PathEscape(connectionID))
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
if parsed.Scheme != "ws" && parsed.Scheme != "wss" {
|
||||
return "", "", errors.New("media websocket URL must use ws or wss")
|
||||
}
|
||||
return parsed.String(), parsed.String(), nil
|
||||
}
|
||||
Reference in New Issue
Block a user