tail-fin-common 0.7.5

Shared infrastructure for tail-fin: error types, page_fetch, cookies, CDP helpers
Documentation
pub mod attachments;
pub mod cookies;
pub mod error;
pub mod html;
pub mod interceptor;
pub mod js;
pub mod page;
pub mod time;
pub mod types;

#[cfg(feature = "cdp")]
pub mod cdp;

pub use error::TailFinError;
pub use night_fury_core::BrowserSession;
pub use night_fury_core::CapturedResponse;
pub use night_fury_core::Selector;
pub use night_fury_core::SessionData;
pub use types::parse_action_result;
pub use types::ActionResult;

// Backward-compat re-exports from tail-fin-core. New code should import
// directly from tail-fin-core. These re-exports may be removed in a
// future release once all call sites have migrated.
pub use tail_fin_core::{
    AuthFailureKind, Credentials, FailureIndicators, SessionManager, SessionStatus, Site, SiteError,
};

use std::path::PathBuf;

/// Returns the tail-fin user data directory: `~/.tail-fin/`
///
/// Creates no directories — callers create subdirs as needed.
pub fn tail_fin_dir() -> PathBuf {
    let home = std::env::var("HOME").unwrap_or_else(|_| ".".into());
    PathBuf::from(home).join(".tail-fin")
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn tail_fin_dir_ends_with_dot_tail_fin() {
        let dir = tail_fin_dir();
        assert!(
            dir.ends_with(".tail-fin"),
            "expected path ending with .tail-fin, got {:?}",
            dir
        );
    }

    #[test]
    fn tail_fin_dir_is_absolute_when_home_is_set() {
        // HOME is normally set in test environments
        if std::env::var("HOME").is_ok() {
            let dir = tail_fin_dir();
            assert!(dir.is_absolute(), "expected absolute path, got {:?}", dir);
        }
    }
}