Skip to content

Commit b283c2b

Browse files
danielrothfusjeapostrophe
authored andcommitted
Add specialized logic for Windows resolution of file:// URIs
1 parent 3b4d67e commit b283c2b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

text-document.rkt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,16 @@
2424
(string-prefix? str "file://"))
2525

2626
(define (uri->path uri)
27-
(substring uri 7))
27+
(cond
28+
[(eq? (system-type 'os) 'windows)
29+
;; If a file URI begins with file:// or file:////, Windows translates it
30+
;; as a UNC path. If it begins with file:///, it's translated to an MS-DOS
31+
;; path. (https://en.wikipedia.org/wiki/File_URI_scheme#Windows_2)
32+
(cond
33+
[(string-prefix? uri "file:////") (substring uri 7)]
34+
[(string-prefix? uri "file:///") (substring uri 8)]
35+
[else (string-append "//" (substring uri 7))])]
36+
[else (substring uri 7)]))
2837

2938
(define (abs-pos->Pos t pos)
3039
(define line (send t position-paragraph pos))

0 commit comments

Comments
 (0)