Skip to content

Commit 186af3c

Browse files
committed
Fix url patching for pre-releases
1 parent 9cf43fd commit 186af3c

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/global/url.ml

+17-13
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,29 @@ let minor v =
5656
| _ -> invalid_arg (v ^ ": invalid version")
5757

5858
let patch v =
59-
match String.split_on_char '.' v with
60-
| x :: y :: z :: _ -> x ^ "." ^ y ^ "." ^ z
61-
| x :: y :: [] ->
62-
(match String.split_on_char '+' y with
63-
| [] -> assert false
64-
| [y] -> x ^ "." ^ y
65-
| y :: _ -> x ^ "." ^ y)
66-
| _ -> invalid_arg (v ^ ": invalid version")
59+
let pre, version =
60+
match String.split_on_char '.' v with
61+
| x :: y :: z :: _ -> false, x ^ "." ^ y ^ "." ^ z
62+
| x :: y :: [] ->
63+
(match String.split_on_char '+' y with
64+
| [] -> assert false
65+
| [y] -> false, x ^ "." ^ y
66+
| y :: _ -> true, x ^ "." ^ y)
67+
| _ -> invalid_arg (v ^ ": invalid version")
68+
in
69+
if pre then "v" ^ version
70+
else "V" ^ version
6771

6872
let v2 = "https://v2.ocaml.org"
69-
let manual_with_version v = "/doc/V" ^ patch v ^ "/refman/index.html"
73+
let manual_with_version v = "/doc/" ^ patch v ^ "/refman/index.html"
7074
let manual = "/refman"
71-
let corelib_with_version v = "/doc/V" ^ patch v ^ "/corelib/index.html"
75+
let corelib_with_version v = "/doc/" ^ patch v ^ "/corelib/index.html"
7276
let corelib = "/corelib"
73-
let stdlib_with_version v = "/doc/V" ^ patch v ^ "/stdlib/index.html"
77+
let stdlib_with_version v = "/doc/" ^ patch v ^ "/stdlib/index.html"
7478
let stdlib = "/stdlib"
75-
let stdlib_manual_with_version v = "/doc/V" ^ patch v ^ "/refman-stdlib/index.html"
79+
let stdlib_manual_with_version v = "/doc/" ^ patch v ^ "/refman-stdlib/index.html"
7680
let stdlib_manual = "/refman-stdlib"
77-
let api_with_version v = "/doc/V" ^ patch v ^ "/api/index.html"
81+
let api_with_version v = "/doc/" ^ patch v ^ "/api/index.html"
7882
let api = "/api"
7983
let books = "/books"
8084
let changelog = "/changelog"

0 commit comments

Comments
 (0)