package appview import "strings" // ResolveHoldURL converts a hold identifier (DID or URL) to an HTTP/HTTPS URL // Handles both formats for backward compatibility: // - DID format: did:web:hold01.atcr.io → https://hold01.atcr.io // - DID with port: did:web:172.28.0.3:8080 → http://172.28.0.3:8080 // - URL format: https://hold.example.com → https://hold.example.com (passthrough) func ResolveHoldURL(holdIdentifier string) string { // If it's already a URL (has scheme), return as-is if strings.HasPrefix(holdIdentifier, "http://") || strings.HasPrefix(holdIdentifier, "https://") { return holdIdentifier } // If it's a DID, convert to URL if strings.HasPrefix(holdIdentifier, "did:web:") { hostname := strings.TrimPrefix(holdIdentifier, "did:web:") // Use HTTP for localhost/IP addresses with ports, HTTPS for domains if strings.Contains(hostname, ":") || strings.Contains(hostname, "127.0.0.1") || strings.Contains(hostname, "localhost") || // Check if it's an IP address (contains only digits and dots in first part) (len(hostname) > 0 && hostname[0] >= '0' && hostname[0] <= '9') { return "http://" + hostname } return "https://" + hostname } // Fallback: assume it's a hostname and use HTTPS return "https://" + holdIdentifier }