"""Shared utilities for ResearchBee backend.""" from typing import Optional def norm_issn(raw: str | None) -> Optional[str]: """ Normalise any ISSN-like string to XXXX-XXXX format. Returns None if input is absent or not 8 digits after stripping. """ if not raw: return None digits = str(raw).strip().upper().replace(" ", "").replace("-", "") return f"{digits[:4]}-{digits[4:]}" if len(digits) == 8 else None