(title: &str, session_id: &str)
| 3815 | } |
| 3816 | |
| 3817 | fn default_export_filename(title: &str, session_id: &str) -> String { |
| 3818 | let mut slug = String::new(); |
| 3819 | let mut prev_dash = false; |
| 3820 | for ch in title.trim().chars() { |
| 3821 | let normalized = if ch.is_ascii_alphanumeric() { |
| 3822 | ch.to_ascii_lowercase() |
| 3823 | } else if ch.is_ascii_whitespace() || ch == '-' || ch == '_' { |
| 3824 | '-' |
| 3825 | } else { |
| 3826 | continue; |
| 3827 | }; |
| 3828 | if normalized == '-' { |
| 3829 | if prev_dash || slug.is_empty() { |
| 3830 | continue; |
| 3831 | } |
| 3832 | prev_dash = true; |
| 3833 | slug.push('-'); |
| 3834 | } else { |
| 3835 | prev_dash = false; |
| 3836 | slug.push(normalized); |
| 3837 | } |
| 3838 | } |
| 3839 | if slug.ends_with('-') { |
| 3840 | slug.pop(); |
| 3841 | } |
| 3842 | if slug.is_empty() { |
| 3843 | let short_id = session_id.chars().take(8).collect::<String>(); |
| 3844 | slug = format!("session-{}", short_id); |
| 3845 | } |
| 3846 | format!("{slug}.md") |
| 3847 | } |
no test coverage detected