Skip to content

Commit

Permalink
colon -> encoded_colon
Browse files Browse the repository at this point in the history
  • Loading branch information
tatchi committed Jun 26, 2022
1 parent d99ef2a commit f07734b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lsp/src/uri0.ml
Original file line number Diff line number Diff line change
Expand Up @@ -113,23 +113,23 @@ let to_string { scheme; authority; path } =

(if not (String.is_empty path) then
let encode = encode ~allow_slash:true in
let colon = "%3A" in
let encoded_colon = "%3A" in
let len = String.length path in
if len >= 3 && path.[0] = '/' && path.[2] = ':' then (
let drive_letter = Char.lowercase_ascii path.[1] in
if drive_letter >= 'a' && drive_letter <= 'z' then (
Buffer.add_char buff '/';
Buffer.add_char buff drive_letter;
Buffer.add_string buff colon;
let s = String.sub path ~pos:3 ~len:(len - 3) |> encode in
Buffer.add_string buff s))
Buffer.add_string buff encoded_colon;
let s = String.sub path ~pos:3 ~len:(len - 3) in
Buffer.add_string buff (encode s)))
else if len >= 2 && path.[1] = ':' then (
let drive_letter = Char.lowercase_ascii path.[0] in
if drive_letter >= 'a' && drive_letter <= 'z' then (
Buffer.add_char buff drive_letter;
Buffer.add_string buff colon;
let s = String.sub path ~pos:2 ~len:(len - 2) |> encode in
Buffer.add_string buff s))
Buffer.add_string buff encoded_colon;
let s = String.sub path ~pos:2 ~len:(len - 2) in
Buffer.add_string buff (encode s)))
else Buffer.add_string buff (encode path));

Buffer.contents buff
Expand Down

0 comments on commit f07734b

Please sign in to comment.