MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / default_export_filename

Function default_export_filename

crates/opencode-tui/src/app/app.rs:3817–3847  ·  view source on GitHub ↗
(title: &str, session_id: &str)

Source from the content-addressed store, hash-verified

3815}
3816
3817fn 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}

Callers 1

Calls 2

newFunction · 0.85
is_emptyMethod · 0.80

Tested by

no test coverage detected