Skip to content

Commit c745d90

Browse files
authored
Merge pull request jantimon#46 from devbrains-com/feature/fix_convertpath_to_posix
Fix convert_path_to_posix for mixed paths
2 parents 1786366 + 24af24d commit c745d90

File tree

1 file changed

+9
-1
lines changed
  • swc/swc-plugin-css-variable/src

1 file changed

+9
-1
lines changed

swc/swc-plugin-css-variable/src/lib.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ fn relative_posix_path(base_path: &str, filename: &str) -> String {
6262
/// - "/foo/bar" -> "/foo/bar"
6363
fn convert_path_to_posix(path: &str) -> String {
6464
lazy_static! {
65-
static ref PATH_REPLACEMENT_REGEX: Regex = Regex::new(r":\\|\\").unwrap();
65+
static ref PATH_REPLACEMENT_REGEX: Regex = Regex::new(r":\\|\\|:/").unwrap();
6666
}
6767

6868
PATH_REPLACEMENT_REGEX.replace_all(path, "/").to_string()
@@ -88,6 +88,14 @@ mod tests {
8888
);
8989
}
9090

91+
#[test]
92+
fn test_relative_path_windows_forward_slash() {
93+
assert_eq!(
94+
relative_posix_path(r"E:\foo", "E:/foo/bar/file.tsx"),
95+
"bar/file.tsx"
96+
);
97+
}
98+
9199
#[test]
92100
fn test_convert_unix_path() {
93101
assert_eq!(convert_path_to_posix(r"/foo/bar"), "/foo/bar");

0 commit comments

Comments
 (0)