UNPKG

a11yanalyze

Version:

A command-line tool for developers and QA engineers to test web pages and websites for WCAG 2.2 AA accessibility compliance

148 lines 4.09 kB
/** * Comprehensive URL Validation and Error Handling System * Provides robust input validation with helpful error messages and auto-correction suggestions */ /** * URL validation result */ export interface UrlValidationResult { /** Whether the URL is valid */ isValid: boolean; /** The validated and normalized URL (if valid) */ normalizedUrl?: string; /** Validation error details */ error?: UrlValidationError; /** Auto-correction suggestions */ suggestions?: string[]; /** Warnings about the URL (even if valid) */ warnings?: string[]; } /** * URL validation error details */ export interface UrlValidationError { /** Error type category */ type: 'format' | 'protocol' | 'domain' | 'network' | 'security' | 'accessibility'; /** Human-readable error message */ message: string; /** Technical error details */ details?: string; /** Original input that caused the error */ input: string; /** Suggested fixes */ fixes?: string[]; } /** * URL validation options */ export interface UrlValidationOptions { /** Allowed protocols */ allowedProtocols?: string[]; /** Whether to allow localhost/local URLs */ allowLocalhost?: boolean; /** Whether to allow IP addresses */ allowIpAddresses?: boolean; /** Whether to check for accessibility-hostile patterns */ checkAccessibilityHostile?: boolean; /** Whether to perform basic network connectivity check */ checkConnectivity?: boolean; /** Whether to allow non-standard ports */ allowNonStandardPorts?: boolean; /** Whether to normalize URLs (add protocol, www, etc.) */ autoNormalize?: boolean; /** Maximum URL length */ maxLength?: number; } /** * Comprehensive URL Validator */ export declare class UrlValidator { private static readonly DEFAULT_OPTIONS; private static readonly COMMON_TYPOS; private static readonly ACCESSIBILITY_HOSTILE_PATTERNS; private static readonly SUSPICIOUS_DOMAINS; private options; private errorLogger; constructor(options?: Partial<UrlValidationOptions>); /** * Validate a URL with comprehensive checking */ validate(input: string): Promise<UrlValidationResult>; /** * Validate multiple URLs */ validateMultiple(inputs: string[]): Promise<UrlValidationResult[]>; /** * Quick validation for common use cases */ isValidUrl(input: string): boolean; /** * Normalize input to handle common formatting issues * @private */ private normalizeInput; /** * Validate URL format * @private */ private validateFormat; /** * Validate URL protocol * @private */ private validateProtocol; /** * Validate domain and hostname * @private */ private validateDomain; /** * Validate security aspects * @private */ private validateSecurity; /** * Validate accessibility-related concerns * @private */ private validateAccessibility; /** * Check network connectivity (basic) * @private */ private checkConnectivity; /** * Check if hostname is an IP address * @private */ private isIpAddress; /** * Generate auto-correction suggestions * @private */ private generateSuggestions; /** * Create validator with preset configurations */ static strict(): UrlValidator; static lenient(): UrlValidator; static development(): UrlValidator; } /** * URL validation error formatter for CLI display */ export declare class UrlErrorFormatter { /** * Format validation error for console display */ static formatError(result: UrlValidationResult): string; /** * Format validation warnings for console display */ static formatWarnings(result: UrlValidationResult): string; /** * Format validation success for console display */ static formatSuccess(result: UrlValidationResult): string; } //# sourceMappingURL=url-validator.d.ts.map