// Reject anything that isn't an http(s) URL or a root-relative path.
// Prevents javascript:/data: scheme values stored in records from executing
// in the browser when later used as <img src> or passed to fetch/IMG helpers.
export function safeMediaUrl(url) {
  if (typeof url !== 'string') return null;
  const u = url.trim();
  if (!u) return null;
  if (/^https?:\/\//i.test(u) || u.startsWith('/')) return u;
  return null;
}