Skip to content

Commit

Permalink
Add specialized logic for Windows resolution of file:// URIs
Browse files Browse the repository at this point in the history
  • Loading branch information
danielrothfus authored and jeapostrophe committed Aug 7, 2019
1 parent 3b4d67e commit b283c2b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion text-document.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,16 @@
(string-prefix? str "file://"))

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

(define (abs-pos->Pos t pos)
(define line (send t position-paragraph pos))
Expand Down

0 comments on commit b283c2b

Please sign in to comment.