@@ -28,6 +28,40 @@ describe("Path Utilities", () => {
2828 } )
2929 } )
3030
31+ describe ( "platform-specific behavior" , ( ) => {
32+ const platforms = [ "win32" , "darwin" , "linux" ]
33+ platforms . forEach ( platform => {
34+ describe ( `on ${ platform } ` , ( ) => {
35+ beforeEach ( ( ) => {
36+ Object . defineProperty ( process , "platform" , { value : platform } )
37+ } )
38+
39+ it ( "should handle root paths correctly" , ( ) => {
40+ const root = platform === "win32" ? "C:\\" : "/"
41+ expect ( arePathsEqual ( root , root + "/" ) ) . toBe ( true )
42+ expect ( arePathsEqual ( root , root + "//" ) ) . toBe ( true )
43+ } )
44+
45+ it ( "should normalize mixed separators" , ( ) => {
46+ const mixedPath = platform === "win32"
47+ ? "C:\\Users/test\\path/file.txt"
48+ : "/Users/test\\path/file.txt"
49+ const normalPath = platform === "win32"
50+ ? "C:\\Users\\test\\path\\file.txt"
51+ : "/Users/test/path/file.txt"
52+ expect ( arePathsEqual ( mixedPath , normalPath ) ) . toBe ( true )
53+ } )
54+
55+ it ( "should handle parent directory traversal" , ( ) => {
56+ const base = platform === "win32" ? "C:\\Users\\test" : "/Users/test"
57+ const path1 = path . join ( base , "dir" , ".." , "file.txt" )
58+ const path2 = path . join ( base , "file.txt" )
59+ expect ( arePathsEqual ( path1 , path2 ) ) . toBe ( true )
60+ } )
61+ } )
62+ } )
63+ } )
64+
3165 describe ( "arePathsEqual" , ( ) => {
3266 describe ( "on Windows" , ( ) => {
3367 beforeEach ( ( ) => {
@@ -75,6 +109,73 @@ describe("Path Utilities", () => {
75109 } )
76110 } )
77111
112+ describe ( "Windows-specific paths" , ( ) => {
113+ beforeEach ( ( ) => {
114+ Object . defineProperty ( process , "platform" , { value : "win32" } )
115+ } )
116+
117+ it ( "should handle drive letter case variations" , ( ) => {
118+ expect ( arePathsEqual ( "C:\\Users\\test" , "c:\\users\\test" ) ) . toBe ( true )
119+ expect ( arePathsEqual ( "D:\\Files\\test" , "d:\\files\\test" ) ) . toBe ( true )
120+ } )
121+
122+ it ( "should handle UNC paths" , ( ) => {
123+ expect ( arePathsEqual (
124+ "\\\\server\\share\\folder" ,
125+ "\\\\SERVER\\share\\folder"
126+ ) ) . toBe ( true )
127+ expect ( arePathsEqual (
128+ "\\\\server\\share\\folder\\" ,
129+ "\\\\server\\share\\folder"
130+ ) ) . toBe ( true )
131+ } )
132+
133+ it ( "should handle extended-length paths" , ( ) => {
134+ const path1 = "\\\\?\\C:\\Very\\Long\\Path"
135+ const path2 = "\\\\?\\C:\\Very\\Long\\Path\\"
136+ expect ( arePathsEqual ( path1 , path2 ) ) . toBe ( true )
137+ } )
138+
139+ it ( "should handle network drive paths" , ( ) => {
140+ expect ( arePathsEqual (
141+ "Z:\\Shared\\Files" ,
142+ "z:\\shared\\files"
143+ ) ) . toBe ( true )
144+ } )
145+ } )
146+
147+ describe ( "path segment variations" , ( ) => {
148+ const platforms = [ "win32" , "darwin" , "linux" ]
149+ platforms . forEach ( platform => {
150+ describe ( `on ${ platform } ` , ( ) => {
151+ beforeEach ( ( ) => {
152+ Object . defineProperty ( process , "platform" , { value : platform } )
153+ } )
154+
155+ it ( "should handle consecutive separators" , ( ) => {
156+ const base = platform === "win32" ? "C:" : ""
157+ const path1 = `${ base } //home///user////file.txt`
158+ const path2 = `${ base } /home/user/file.txt`
159+ expect ( arePathsEqual ( path1 , path2 ) ) . toBe ( true )
160+ } )
161+
162+ it ( "should handle current directory references" , ( ) => {
163+ const base = platform === "win32" ? "C:" : ""
164+ const path1 = `${ base } /./home/./user/./file.txt`
165+ const path2 = `${ base } /home/user/file.txt`
166+ expect ( arePathsEqual ( path1 , path2 ) ) . toBe ( true )
167+ } )
168+
169+ it ( "should handle complex parent directory traversal" , ( ) => {
170+ const base = platform === "win32" ? "C:" : ""
171+ const path1 = `${ base } /a/b/c/../../d/../e/f/../g`
172+ const path2 = `${ base } /a/e/g`
173+ expect ( arePathsEqual ( path1 , path2 ) ) . toBe ( true )
174+ } )
175+ } )
176+ } )
177+ } )
178+
78179 describe ( "edge cases" , ( ) => {
79180 it ( "should handle undefined paths" , ( ) => {
80181 expect ( arePathsEqual ( undefined , undefined ) ) . toBe ( true )
0 commit comments