this repo has no description
1/**
2 * Validate that a string is a valid TID (Timestamp ID)
3 * TIDs are base36 encoded and should be 13 characters
4 */
5export function isValidTID(tid: string): boolean {
6 if (!tid || typeof tid !== "string") return false;
7 // TID should be 13 characters of base36 (0-9, a-z)
8 return /^[0-9a-z]{13}$/.test(tid);
9}
10
11/**
12 * Validate that a URL is a valid HTTPS URL
13 */
14export function isValidHttpsUrl(url: string): boolean {
15 try {
16 const parsed = new URL(url);
17 return parsed.protocol === "https:";
18 } catch {
19 return false;
20 }
21}
22
23/**
24 * Sanitize a string for safe display (basic XSS prevention)
25 * Note: Hono's html template already escapes, but this is defense in depth
26 */
27export function sanitizeString(str: string, maxLength: number = 1000): string {
28 if (!str || typeof str !== "string") return "";
29 return str.slice(0, maxLength);
30}