@@ -99,6 +99,27 @@ assertEquals(
99
99
);
100
100
```
101
101
102
+ This function does not handle path separator differences among platforms (Unix
103
+ uses ` / ` but Windows uses ` \ ` ). That's why it's recommended to normalize the
104
+ ` expr ` with [ ` toFileUrl ` ] ( https://deno.land/std/path#tofileurl ) before when
105
+ constructing a buffer name from a real path. For example
106
+
107
+ ``` typescript
108
+ import { assertEquals } from " https://deno.land/std/testing/asserts.ts" ;
109
+ import * as path from " https://deno.land/std/path/mod.ts" ;
110
+ import { format } from " https://deno.land/x/denops_std/bufname/mod.ts" ;
111
+
112
+ // NOTE:
113
+ // Works only on Windows (Use path.win32.toFileUrl instead on other platforms)
114
+ assertEquals (
115
+ format ({
116
+ scheme: " denops" ,
117
+ expr: path .toFileUrl (" C:\\ Users\J ohn Titor\t est.git" ).pathname ,
118
+ }),
119
+ " denops:///C:/Users/John%20Titor/test.git" ,
120
+ );
121
+ ```
122
+
102
123
### parse
103
124
104
125
Use ` parse() ` to parse Vim's buffer name and get a ` Bufname ` instance like
@@ -151,3 +172,26 @@ assertEquals(
151
172
},
152
173
);
153
174
```
175
+
176
+ This function does not handle path separator differences among platforms. That's
177
+ why it's recommended to restore the ` expr ` with
178
+ [ ` fromFileUrl ` ] ( https://deno.land/std/path#fromfileurl ) after if a buffer name
179
+ was constructed from a real path. For example
180
+
181
+ ``` typescript
182
+ import { assertEquals } from " https://deno.land/std/testing/asserts.ts" ;
183
+ import * as path from " https://deno.land/std/path/mod.ts" ;
184
+ import { parse } from " https://deno.land/x/denops_std/bufname/mod.ts" ;
185
+
186
+ const bufname = parse (" denops:///C:/Users/John%20Titor/test.git" );
187
+ assertEquals (bufname , {
188
+ scheme: " denops" ,
189
+ expr: " /C:/Users/John Titor/test.git" ,
190
+ });
191
+ // NOTE:
192
+ // Works only on Windows (Use path.win32.fromFileUrl instead on other platforms)
193
+ assertEquals (
194
+ path .fromFileUrl (` file://${bufname .expr } ` ),
195
+ " C:\\ Users\\ John Titor\\ test.git" ,
196
+ );
197
+ ```
0 commit comments