INNER CODE UNIT · TypeScript
sanitizeImageUrl
Hash-Studios/Prism · infra/cloudflare/worker/src/index.ts:689
function sanitizeImageUrl(value: string): string {
if (!isNonEmptyString(value)) {
return '';
}
try {
const parsed = new URL(value);
if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {
return '';
}
return parsed.toString();
} catch {
return '';
}
}
async function generateUniqueCode(env: Env): Promise<string> {
for (let i = 0; i < 10; i += 1) {
const code = generateCode(8);