From b283c2baf65bf3122bcc46b26206934bdabbd5bd Mon Sep 17 00:00:00 2001 From: Daniel Rothfus Date: Tue, 6 Aug 2019 20:28:48 -0700 Subject: [PATCH] Add specialized logic for Windows resolution of file:// URIs --- text-document.rkt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/text-document.rkt b/text-document.rkt index 6867e5e..6a026d0 100644 --- a/text-document.rkt +++ b/text-document.rkt @@ -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))