
pub struct UrlBuilder {
    base_url: String,
}

impl UrlBuilder {
    pub fn new() -> Self {
        Self {
            base_url: std::env::var("API_BASE_URL")
                .unwrap_or_else(|_| "https://api.rockvilletollandsda.church".to_string()),
        }
    }
    
    
    pub fn build_image_url(&self, path: &str) -> String {
        if path.is_empty() {
            return String::new();
        }
        
        // If it's already a full URL, return as-is
        if path.starts_with("http://") || path.starts_with("https://") {
            return path.to_string();
        }
        
        let cleaned_path = path.trim_start_matches('/');
        format!("{}/{}", self.base_url, cleaned_path)
    }
    
    pub fn build_upload_url(&self, path: &str) -> String {
        self.build_image_url(&format!("uploads/{}", path.trim_start_matches("uploads/")))
    }
    
}

impl Default for UrlBuilder {
    fn default() -> Self {
        Self::new()
    }
}

