String extractRegion(Uri uri) { final parts = uri.host.split('.'); if (parts.length == 4 && parts[1].contains('-')) return parts[1]; throw Exception('Unable to detect region in ${uri.host}.'); }