Skip to content

Commit

Permalink
Update pathutil.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
mtshiba committed Jun 22, 2024
1 parent 72c36bd commit e7b7f99
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/erg_common/pathutil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ pub fn remove_verbatim(path: &Path) -> String {
/// /users/foo/torch/src/lib.d.er -> torch
/// foo/__pycache__/__init__.d.er -> foo
/// math.d.er -> math
/// foo.py -> foo
/// ```
/// FIXME: split by `.` instead of `/`
pub fn mod_name(path: &Path) -> Str {
Expand All @@ -264,6 +265,7 @@ pub fn mod_name(path: &Path) -> Str {
.trim_end_matches("lib.d.er")
.trim_end_matches(".d.er")
.trim_end_matches(".d")
.trim_end_matches(".py")
.to_string()
})
.collect::<Vec<_>>()
Expand All @@ -290,6 +292,7 @@ pub fn mod_name(path: &Path) -> Str {
c.trim_end_matches("lib.d.er")
.trim_end_matches(".d.er")
.trim_end_matches(".d")
.trim_end_matches(".py")
.to_string()
})
.collect::<Vec<_>>()
Expand All @@ -303,6 +306,7 @@ pub fn mod_name(path: &Path) -> Str {
.unwrap()
.to_string_lossy()
.trim_end_matches(".d.er")
.trim_end_matches(".py")
.to_string();
let mut parents = path.components().rev().skip(1);
while let Some(parent) = parents.next() {
Expand Down

0 comments on commit e7b7f99

Please sign in to comment.