Files
zeekay c4c9a0aa95 Fix all remaining issues found by CTO agent swarm
High Priority Fixes:
- ✅ Add View Details button for app navigation to detail pages
- ✅ Add footer links for Guidelines, Terms, and Privacy pages
- ✅ Rename data files to match store.json IDs (hanzo→shinkai prefix)
- ✅ Fix WalletConnect projectId - make optional to avoid console errors
- ✅ Add favicon using Hanzo logo

Medium Priority Fixes:
- ✅ Remove console statements from production code
- ✅ Remove unused Github import from page-client
- ✅ Add URL sanitization for security (XSS prevention)
- ✅ Create URL validation utility function

Code Quality Improvements:
- ✅ Add TypeScript type definitions for @hanzo/ui
- ✅ Add explicit types for event handlers
- ✅ Add .env.example for WalletConnect setup
- ✅ Add LLM.md with comprehensive documentation
- ✅ Fix implicit any types in test files

Security Enhancements:
- Sanitize all external URLs before rendering
- Validate URL protocols (http/https only)
- Prevent XSS through URL injection

Files Changed:
- app/page.tsx - navigation, footer links, URL validation
- app/apps/[id]/page-client.tsx - URL validation, remove console
- app/apps/[id]/page.tsx - remove console
- lib/wagmi.ts - make WalletConnect optional
- lib/url-utils.ts - NEW: URL validation utility
- types/hanzo-ui.d.ts - NEW: TypeScript declarations
- .env.example - NEW: environment variable template
- .github/workflows/deploy.yml - add WalletConnect env var
- public/favicon.ico - NEW: Hanzo logo favicon
- data files - rename to match IDs
2025-11-06 02:04:48 -08:00

30 lines
756 B
TypeScript

/**
* Validates and sanitizes a URL for safe usage
* @param url - The URL to validate
* @returns The sanitized URL or null if invalid
*/
export function sanitizeUrl(url: string): string | null {
if (!url || typeof url !== 'string') {
return null;
}
try {
// Add https:// if no protocol is specified
const urlWithProtocol = url.startsWith('http') ? url : `https://${url}`;
// Parse and validate the URL
const parsedUrl = new URL(urlWithProtocol);
// Only allow http and https protocols
if (parsedUrl.protocol !== 'http:' && parsedUrl.protocol !== 'https:') {
return null;
}
// Return the sanitized URL
return parsedUrl.toString();
} catch {
// Invalid URL
return null;
}
}