Skip to content

Commit

Permalink
Add a fix for windows for proper URI handling (#87) (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
vanyle authored May 9, 2022
1 parent 3f9db4d commit 91c6340
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/nimlsp.nim
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,18 @@ proc pathToUri(path: string): string =
# the / character, meaning a full file path can be passed in without breaking
# it.
result = newStringOfCap(path.len + path.len shr 2) # assume 12% non-alnum-chars
when defined(windows):
result.add '/'
for c in path:
case c
# https://tools.ietf.org/html/rfc3986#section-2.3
of 'a'..'z', 'A'..'Z', '0'..'9', '-', '.', '_', '~', '/': add(result, c)
of '\\':
when defined(windows):
result.add '/'
else:
result.add '%'
result.add toHex(ord(c), 2)
else:
add(result, '%')
add(result, toHex(ord(c), 2))
Expand Down

0 comments on commit 91c6340

Please sign in to comment.