Skip to main content

tail_fin_common/
lib.rs

1pub mod attachments;
2pub mod cookies;
3pub mod error;
4pub mod html;
5pub mod interceptor;
6pub mod js;
7pub mod page;
8pub mod time;
9pub mod types;
10
11#[cfg(feature = "cdp")]
12pub mod cdp;
13
14pub use error::TailFinError;
15pub use night_fury_core::BrowserSession;
16pub use night_fury_core::CapturedResponse;
17pub use night_fury_core::Selector;
18pub use night_fury_core::SessionData;
19pub use types::parse_action_result;
20pub use types::ActionResult;
21
22// Backward-compat re-exports from tail-fin-core. New code should import
23// directly from tail-fin-core. These re-exports may be removed in a
24// future release once all call sites have migrated.
25pub use tail_fin_core::{
26    AuthFailureKind, Credentials, FailureIndicators, SessionManager, SessionStatus, Site, SiteError,
27};
28
29use std::path::PathBuf;
30
31/// Returns the tail-fin user data directory: `~/.tail-fin/`
32///
33/// Creates no directories — callers create subdirs as needed.
34pub fn tail_fin_dir() -> PathBuf {
35    let home = std::env::var("HOME").unwrap_or_else(|_| ".".into());
36    PathBuf::from(home).join(".tail-fin")
37}
38
39#[cfg(test)]
40mod tests {
41    use super::*;
42
43    #[test]
44    fn tail_fin_dir_ends_with_dot_tail_fin() {
45        let dir = tail_fin_dir();
46        assert!(
47            dir.ends_with(".tail-fin"),
48            "expected path ending with .tail-fin, got {:?}",
49            dir
50        );
51    }
52
53    #[test]
54    fn tail_fin_dir_is_absolute_when_home_is_set() {
55        // HOME is normally set in test environments
56        if std::env::var("HOME").is_ok() {
57            let dir = tail_fin_dir();
58            assert!(dir.is_absolute(), "expected absolute path, got {:?}", dir);
59        }
60    }
61}