Skip to main content

crap4rust/analysis/
normalize_path.rs

1// Copyright 2026 Umberto Gotti <umberto.gotti@umbertogotti.dev>
2// Licensed under the MIT License
3// SPDX-License-Identifier: MIT
4
5use std::path::Path;
6
7pub fn normalize_path(path: &Path) -> String {
8    let normalized = path
9        .canonicalize()
10        .unwrap_or_else(|_| path.to_path_buf())
11        .to_string_lossy()
12        .replace('\\', "/");
13    if cfg!(windows) {
14        normalized.to_lowercase()
15    } else {
16        normalized
17    }
18}