Skip to content

Commit c4e8ffb

Browse files
committed
add more chars to url encode
1 parent 48d1ce6 commit c4e8ffb

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

analysis/src/Hover.ml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,33 @@ open SharedTypes
22

33
let codeBlock code = Printf.sprintf "```rescript\n%s\n```" code
44

5+
(* Light weight, hopefully-enough-for-the-purpose fn to encode URI components.
6+
Built to handle the reserved characters listed in
7+
https://en.wikipedia.org/wiki/Percent-encoding. Note that this function is not
8+
general purpose, rather it's currently only for URL encoding the argument list
9+
passed to command links in markdown. *)
510
let encodeURIComponent text =
611
let ln = String.length text in
712
let buf = Buffer.create ln in
813
let rec loop i =
914
if i < ln then (
1015
(match text.[i] with
1116
| '"' -> Buffer.add_string buf "%22"
17+
| '\'' -> Buffer.add_string buf "%22"
1218
| ':' -> Buffer.add_string buf "%3A"
19+
| ';' -> Buffer.add_string buf "%3B"
1320
| '/' -> Buffer.add_string buf "%2F"
1421
| '\\' -> Buffer.add_string buf "%5C"
1522
| ',' -> Buffer.add_string buf "%2C"
1623
| '&' -> Buffer.add_string buf "%26"
1724
| '[' -> Buffer.add_string buf "%5B"
1825
| ']' -> Buffer.add_string buf "%5D"
26+
| '#' -> Buffer.add_string buf "%23"
27+
| '$' -> Buffer.add_string buf "%24"
28+
| '+' -> Buffer.add_string buf "%2B"
29+
| '=' -> Buffer.add_string buf "%3D"
30+
| '?' -> Buffer.add_string buf "%3F"
31+
| '@' -> Buffer.add_string buf "%40"
1932
| c -> Buffer.add_char buf c);
2033
loop (i + 1))
2134
in

0 commit comments

Comments
 (0)