@@ -31,15 +31,8 @@ impl Function for Path {
31
31
debug ! ( "Executing path function with args: {:?}" , args) ;
32
32
33
33
let mut path = PathBuf :: new ( ) ;
34
- let mut first = true ;
35
34
for arg in args {
36
35
if let Value :: String ( s) = arg {
37
- // if first argument is a drive letter, add it with a separator suffix as PathBuf.push() doesn't add it
38
- if first && s. len ( ) == 2 && s. chars ( ) . nth ( 1 ) . unwrap ( ) == ':' {
39
- path. push ( s. to_owned ( ) + std:: path:: MAIN_SEPARATOR . to_string ( ) . as_str ( ) ) ;
40
- first = false ;
41
- continue ;
42
- }
43
36
path. push ( s) ;
44
37
} else {
45
38
return Err ( DscError :: Parser ( "Arguments must all be strings" . to_string ( ) ) ) ;
@@ -60,14 +53,14 @@ mod tests {
60
53
#[ test]
61
54
fn start_with_drive_letter ( ) {
62
55
let mut parser = Statement :: new ( ) . unwrap ( ) ;
63
- let result = parser. parse_and_execute ( "[path('C:','test')]" , & Context :: new ( ) ) . unwrap ( ) ;
56
+ let result = parser. parse_and_execute ( "[path('C:\\ ','test')]" , & Context :: new ( ) ) . unwrap ( ) ;
64
57
assert_eq ! ( result, format!( "C:{SEPARATOR}test" ) ) ;
65
58
}
66
59
67
60
#[ test]
68
61
fn drive_letter_in_middle ( ) {
69
62
let mut parser = Statement :: new ( ) . unwrap ( ) ;
70
- let result = parser. parse_and_execute ( "[path('a','C:','test')]" , & Context :: new ( ) ) . unwrap ( ) ;
63
+ let result = parser. parse_and_execute ( "[path('a','C:\\ ','test')]" , & Context :: new ( ) ) . unwrap ( ) ;
71
64
72
65
// if any part of the path is absolute, it replaces it instead of appending on Windows
73
66
#[ cfg( target_os = "windows" ) ]
@@ -81,11 +74,11 @@ mod tests {
81
74
#[ test]
82
75
fn multiple_drive_letters ( ) {
83
76
let mut parser = Statement :: new ( ) . unwrap ( ) ;
84
- let result = parser. parse_and_execute ( "[path('C:','D:','test')]" , & Context :: new ( ) ) . unwrap ( ) ;
77
+ let result = parser. parse_and_execute ( "[path('C:\\ ','D:\\ ','test')]" , & Context :: new ( ) ) . unwrap ( ) ;
85
78
86
79
// if any part of the path is absolute, it replaces it instead of appending on Windows
87
80
#[ cfg( target_os = "windows" ) ]
88
- assert_eq ! ( result, format!( "D:test" ) ) ;
81
+ assert_eq ! ( result, format!( "D:\\ test" ) ) ;
89
82
90
83
// non-Windows, the colon is a valid character in a path
91
84
#[ cfg( not( target_os = "windows" ) ) ]
0 commit comments