@@ -72,22 +72,47 @@ public string ConvertClientPathToDebugger(string clientPath)
7272 string hostWorkspace = Environment . GetEnvironmentVariable ( "OSCRIPT_DEBUGWORKSPACE_HOST" ) ;
7373 string remoteWorkspace = Environment . GetEnvironmentVariable ( "OSCRIPT_DEBUGWORKSPACE_REMOTE" ) ;
7474
75- if ( ! string . IsNullOrEmpty ( hostWorkspace ) && ! string . IsNullOrEmpty ( remoteWorkspace ) )
75+ if ( ! string . IsNullOrWhiteSpace ( hostWorkspace ) && ! string . IsNullOrWhiteSpace ( remoteWorkspace ) )
7676 {
77- string normalizedClientPath = clientPath . Replace ( '/' , '\\ ' ) ;
78- string normalizedHostWorkspace = hostWorkspace . Replace ( '/' , '\\ ' ) ;
77+
78+ string normalizedClientPath = clientPath . Replace ( '/' , '\\ ' ) . Trim ( ) ;
79+ string normalizedHostWorkspace = hostWorkspace . Replace ( '/' , '\\ ' ) . Trim ( ) ;
7980
81+ if ( ! normalizedHostWorkspace . EndsWith ( "\\ " ) )
82+ normalizedHostWorkspace += "\\ " ;
83+
84+ if ( ! normalizedClientPath . EndsWith ( "\\ " ) )
85+ normalizedClientPath += "\\ " ;
86+
8087 if ( normalizedClientPath . StartsWith ( normalizedHostWorkspace , StringComparison . OrdinalIgnoreCase ) )
8188 {
89+
8290 string relativePath = normalizedClientPath . Substring ( normalizedHostWorkspace . Length ) ;
91+ relativePath = relativePath . TrimStart ( '\\ ' ) ;
8392
84- string normalizedRemote = remoteWorkspace . Replace ( '\\ ' , '/' ) ;
85- string normalizedRelative = relativePath . Replace ( ' \\ ' , '/' ) ;
93+ string normalizedRemote = remoteWorkspace . Trim ( ) . Replace ( '\\ ' , '/' ) ;
94+ normalizedRemote = normalizedRemote . TrimEnd ( '/' ) ;
8695
87- string result = normalizedRemote . TrimEnd ( '/' ) + "/" + normalizedRelative . TrimStart ( '/' ) ;
88-
96+ string result = string . IsNullOrEmpty ( relativePath )
97+ ? normalizedRemote
98+ : normalizedRemote + "/" + relativePath . Replace ( '\\ ' , '/' ) ;
99+
100+ Console . Error . WriteLine ( $ "Path mapped: '{ clientPath } ' -> '{ result } '") ;
89101 return result ;
90102 }
103+ else
104+ {
105+ Console . Error . WriteLine ( $ "Path mapping skipped: '{ clientPath } ' doesn't start with '{ hostWorkspace } '") ;
106+ }
107+ }
108+ else
109+ {
110+ if ( string . IsNullOrWhiteSpace ( hostWorkspace ) && string . IsNullOrWhiteSpace ( remoteWorkspace ) )
111+ Console . Error . WriteLine ( "Path mapping: both OSCRIPT_DEBUGWORKSPACE_HOST and OSCRIPT_DEBUGWORKSPACE_REMOTE are not set" ) ;
112+ else if ( string . IsNullOrWhiteSpace ( hostWorkspace ) )
113+ Console . Error . WriteLine ( "Path mapping: OSCRIPT_DEBUGWORKSPACE_HOST is not set or empty" ) ;
114+ else if ( string . IsNullOrWhiteSpace ( remoteWorkspace ) )
115+ Console . Error . WriteLine ( "Path mapping: OSCRIPT_DEBUGWORKSPACE_REMOTE is not set or empty" ) ;
91116 }
92117
93118 if ( DebuggerPathsAreUri ) {
0 commit comments