ocaml
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Correct handling of asset URIs

URI_scheme.named_uri is a little dodgy: it uses the absence of a file
extension as a heuristic to decide whether the URI should have a slash
put at the end. This is the "right" behaviour for tree resources, but
not for assets.

Although it would be good to clean this up more thoroughly, I have for
now introduced a new file_uri function that is used for assets.

References ~jonsterling/forester#193

+5 -2
+1 -1
lib/compiler/Asset_router.ml
··· 26 26 let cid = Cid.v ~version:`Cidv1 ~codec:`Raw ~base:`Base32 ~hash in 27 27 let cid_str = Cid.to_string cid in 28 28 let ext = Filename.extension normalized in 29 - let uri = URI_scheme.named_uri ~base:config.url (cid_str ^ ext) in 29 + let uri = URI_scheme.file_uri ~base:config.url ~ext cid_str in 30 30 Hashtbl.add router normalized uri; 31 31 uri 32 32
+1 -1
lib/compiler/Eval.ml
··· 370 370 | Syndicate_query_as_json_blob -> 371 371 let name = pop_text_arg ~env ~loc in 372 372 let blob_uri = 373 - URI_scheme.named_uri ~base:env.config.url @@ name ^ ".json" 373 + URI_scheme.file_uri ~base:env.config.url ~ext: ".json" name 374 374 in 375 375 let query_arg = eval_pop_arg ~env ~loc in 376 376 begin match query_arg.value with
+2
lib/core/URI_scheme.ml
··· 6 6 7 7 open Forester_prelude 8 8 9 + let file_uri ~base ~ext name = URI.resolve ~base @@ URI.make ~path:[name ^ ext] () 10 + 9 11 let named_uri ~base name = 10 12 URI.resolve ~base 11 13 @@
+1
lib/core/URI_scheme.mli
··· 4 4 * SPDX-License-Identifier: GPL-3.0-or-later 5 5 *) 6 6 7 + val file_uri : base:URI.t -> ext:string -> string -> URI.t 7 8 val named_uri : base:URI.t -> string -> URI.t 8 9 val lsp_uri_to_uri : base:URI.t -> Lsp.Uri.t -> URI.t 9 10 val split_addr : URI.t -> (string option * int) option