Skip to content

Commit

Permalink
fix: normalize Windows paths in ModuleId constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
sorrycc committed Jan 8, 2025
1 parent dfe3164 commit 31f7883
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions crates/mako/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ impl PartialOrd for ModuleId {
impl ModuleId {
// we use absolute path as module id now
pub fn new(id: String) -> Self {
Self { id }
Self {
id: win_path(id.as_str()),
}
}

pub fn generate(&self, context: &Arc<Context>) -> String {
Expand All @@ -304,20 +306,22 @@ impl ModuleId {

impl From<String> for ModuleId {
fn from(id: String) -> Self {
Self { id }
Self {
id: win_path(id.as_str()),
}
}
}

impl From<&str> for ModuleId {
fn from(id: &str) -> Self {
Self { id: id.to_string() }
Self { id: win_path(id) }
}
}

impl From<PathBuf> for ModuleId {
fn from(path: PathBuf) -> Self {
Self {
id: path.to_string_lossy().to_string(),
id: win_path(path.to_string_lossy().to_string().as_str()),
}
}
}
Expand Down

0 comments on commit 31f7883

Please sign in to comment.