# home/api/utils.py

def build_absolute_media_url(request, url):
    """
    Ubah media URL relatif menjadi absolute URL
    Contoh:
      /media/logo.webp
      -> https://tenant-a.localhost/media/logo.webp
    """
    if not url:
        return None

    # Jika sudah absolute, kembalikan apa adanya
    if url.startswith("http://") or url.startswith("https://"):
        return url

    return request.build_absolute_uri(url)