- Adjusted .prettierrc to ensure consistent formatting with a newline at the end of the file. - Reformatted eslint.config.mjs for improved readability by aligning array elements. - Updated pnpm-lock.yaml to use single quotes for consistency across dependencies. - Simplified worktree setup in .cursor/worktrees.json for cleaner configuration. - Enhanced documentation in .cursor/plans to clarify architecture refactoring. - Refactored various service files for improved readability and maintainability, including rate-limiting and auth services. - Updated imports and exports across multiple files for consistency and clarity. - Improved error handling and logging in service methods to enhance debugging capabilities. - Streamlined utility functions for better performance and maintainability across the domain packages.
29 lines
545 B
TypeScript
29 lines
545 B
TypeScript
/**
|
|
* Toolkit - URL Utilities
|
|
*
|
|
* URL parsing and manipulation utilities.
|
|
* For URL validation, use functions from common/validation.ts
|
|
*/
|
|
|
|
/**
|
|
* Ensure URL has protocol
|
|
*/
|
|
export function ensureProtocol(url: string, protocol = "https"): string {
|
|
if (!/^https?:\/\//i.test(url)) {
|
|
return `${protocol}://${url}`;
|
|
}
|
|
return url;
|
|
}
|
|
|
|
/**
|
|
* Extract hostname from URL
|
|
*/
|
|
export function getHostname(url: string): string | null {
|
|
try {
|
|
const parsed = new URL(url);
|
|
return parsed.hostname;
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|