File tree Expand file tree Collapse file tree 2 files changed +41
-3
lines changed Expand file tree Collapse file tree 2 files changed +41
-3
lines changed Original file line number Diff line number Diff line change @@ -356,8 +356,8 @@ function logError(...args: any[]) {
356
356
logger . error ( logArgsToString ( args ) ) ;
357
357
}
358
358
359
- function findPathSeparator ( filePath : string ) {
360
- return filePath . includes ( '/ ' ) ? '/ ' : '\\ ' ;
359
+ export function findPathSeparator ( filePath : string ) {
360
+ return filePath . includes ( '\\ ' ) ? '\\ ' : '/ ' ;
361
361
}
362
362
363
363
// Comparing two different file paths while ignoring any different path separators.
Original file line number Diff line number Diff line change 4
4
*--------------------------------------------------------*/
5
5
6
6
import * as assert from 'assert' ;
7
- import { normalizeSeparators } from '../../src/debugAdapter/goDebug' ;
7
+ import { findPathSeparator , normalizeSeparators } from '../../src/debugAdapter/goDebug' ;
8
8
9
9
suite ( 'NormalizeSeparators Tests' , ( ) => {
10
10
test ( 'fix separator' , ( ) => {
@@ -94,4 +94,42 @@ suite('NormalizeSeparators Tests', () => {
94
94
assert . strictEqual ( got , tc . want ) ;
95
95
}
96
96
} ) ;
97
+
98
+ test ( 'find path separator' , ( ) => {
99
+ const tt = [
100
+ {
101
+ input : '../path/to/file' ,
102
+ want : '/'
103
+ } ,
104
+ {
105
+ input : './path/to/file' ,
106
+ want : '/'
107
+ } ,
108
+ {
109
+ input : '..\\path\\to\\file' ,
110
+ want : '\\'
111
+ } ,
112
+ {
113
+ input : '.\\path\\to\\file' ,
114
+ want : '\\'
115
+ } ,
116
+ {
117
+ input : '/path/to/../file' ,
118
+ want : '/'
119
+ } ,
120
+ {
121
+ input : 'c:\\path\\to\\..\\file' ,
122
+ want : '\\'
123
+ } ,
124
+ {
125
+ input : '' ,
126
+ want : '/'
127
+ }
128
+ ] ;
129
+
130
+ for ( const tc of tt ) {
131
+ const got = findPathSeparator ( tc . input ) ;
132
+ assert . strictEqual ( got , tc . want ) ;
133
+ }
134
+ } ) ;
97
135
} ) ;
You can’t perform that action at this time.
0 commit comments