Skip to content

Commit

Permalink
Add additional check in path normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
fsktom committed Jul 14, 2024
1 parent e23d939 commit cf0a738
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 48 deletions.
36 changes: 18 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 26 additions & 26 deletions endsong_ui/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions endsong_ui/src/plot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ fn normalize_path(path: &str) -> String {
}

// https://stackoverflow.com/a/1976050
if new_path.is_empty() {
new_path.push('_');
if new_path.is_empty() || new_path == "." {
new_path = "_".into();
}

new_path
Expand All @@ -157,8 +157,9 @@ mod tests {
assert_eq!(normalize_path(" "), "_");
assert_eq!(normalize_path(" "), "___");

// empty should be changed
// empty/only dot should be changed (Windows)
assert_eq!(normalize_path(""), "_");
assert_eq!(normalize_path("."), "_");

assert_eq!(normalize_path(" A|B<>B? "), "_A_B__B__");

Expand Down
3 changes: 2 additions & 1 deletion endsong_ui/src/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ impl TraceType {
}
}

/// Formats date for x-axis to `%Y-%m-%d %H:%M`
/// Formats date for x-axis to `%Y-%m-%d %H:%M` to make sure plotly
/// scales the x-axis properly
///
/// I.e. "2016-09-01 15:06"
fn format_date(date: &DateTime<Local>) -> String {
Expand Down

0 comments on commit cf0a738

Please sign in to comment.