( value: string | null | undefined, paramName = 'projectId' )
| 1454 | * @returns ValidationResult |
| 1455 | */ |
| 1456 | export function validateSupabaseProjectId( |
| 1457 | value: string | null | undefined, |
| 1458 | paramName = 'projectId' |
| 1459 | ): ValidationResult { |
| 1460 | if (value === null || value === undefined || value === '') { |
| 1461 | return { |
| 1462 | isValid: false, |
| 1463 | error: `${paramName} is required`, |
| 1464 | } |
| 1465 | } |
| 1466 | |
| 1467 | if (!/^[a-z0-9]+$/.test(value)) { |
| 1468 | logger.warn('Invalid Supabase project ID format', { |
| 1469 | paramName, |
| 1470 | value: value.substring(0, 50), |
| 1471 | }) |
| 1472 | return { |
| 1473 | isValid: false, |
| 1474 | error: `${paramName} must contain only lowercase alphanumeric characters`, |
| 1475 | } |
| 1476 | } |
| 1477 | |
| 1478 | if (value.length < 10 || value.length > 40) { |
| 1479 | logger.warn('Supabase project ID length invalid', { |
| 1480 | paramName, |
| 1481 | length: value.length, |
| 1482 | }) |
| 1483 | return { |
| 1484 | isValid: false, |
| 1485 | error: `${paramName} must be between 10 and 40 characters`, |
| 1486 | } |
| 1487 | } |
| 1488 | |
| 1489 | return { isValid: true, sanitized: value } |
| 1490 | } |
| 1491 | |
| 1492 | export function isMicrosoftContentUrl(url: string): boolean { |
| 1493 | let hostname: string |
no test coverage detected