-- Fix security warning: Set search_path on extract_cf_image_id function
CREATE OR REPLACE FUNCTION extract_cf_image_id(url TEXT)
RETURNS TEXT
LANGUAGE plpgsql
IMMUTABLE
SECURITY DEFINER
SET search_path = public
AS $$
BEGIN
  -- Extract ID from imagedelivery.net URL pattern
  -- Pattern: https://imagedelivery.net/{account-hash}/{image-id}/{variant}
  RETURN (regexp_match(url, '/([a-f0-9-]+)/[a-z0-9]+$'))[1];
END;
$$;