Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion swc/swc-plugin-css-variable/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fn relative_posix_path(base_path: &str, filename: &str) -> String {
/// - "/foo/bar" -> "/foo/bar"
fn convert_path_to_posix(path: &str) -> String {
lazy_static! {
static ref PATH_REPLACEMENT_REGEX: Regex = Regex::new(r":\\|\\").unwrap();
static ref PATH_REPLACEMENT_REGEX: Regex = Regex::new(r":\\|\\|:/").unwrap();
}

PATH_REPLACEMENT_REGEX.replace_all(path, "/").to_string()
Expand All @@ -88,6 +88,14 @@ mod tests {
);
}

#[test]
fn test_relative_path_windows_forward_slash() {
assert_eq!(
relative_posix_path(r"E:\foo", "E:/foo/bar/file.tsx"),
"bar/file.tsx"
);
}

#[test]
fn test_convert_unix_path() {
assert_eq!(convert_path_to_posix(r"/foo/bar"), "/foo/bar");
Expand Down