From 063c0469335a19b3bf0335bda7586716e05ca029 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Thu, 31 Aug 2023 23:28:15 -0400 Subject: [PATCH] remove use of String.ends_with for compat with 4.08 --- src/client-cohttp-lwt/opentelemetry_client_cohttp_lwt.ml | 5 ++--- src/client-ocurl/opentelemetry_client_ocurl.ml | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/client-cohttp-lwt/opentelemetry_client_cohttp_lwt.ml b/src/client-cohttp-lwt/opentelemetry_client_cohttp_lwt.ml index 9241e9c1..8e617852 100644 --- a/src/client-cohttp-lwt/opentelemetry_client_cohttp_lwt.ml +++ b/src/client-cohttp-lwt/opentelemetry_client_cohttp_lwt.ml @@ -95,7 +95,7 @@ end = struct ('a, error) result Lwt.t = let url = let url = config.url in - if String.ends_with url ~suffix:"/" then + if url <> "" && String.get url (String.length url - 1) = '/' then String.sub url 0 (String.length url - 1) else url @@ -115,8 +115,7 @@ end = struct try%lwt let+ r = Httpc.post ~headers ~body uri in Ok r - with e -> - Lwt.return @@ Error e + with e -> Lwt.return @@ Error e in match r with | Error e -> diff --git a/src/client-ocurl/opentelemetry_client_ocurl.ml b/src/client-ocurl/opentelemetry_client_ocurl.ml index f8c08e4c..2ad599f1 100644 --- a/src/client-ocurl/opentelemetry_client_ocurl.ml +++ b/src/client-ocurl/opentelemetry_client_ocurl.ml @@ -125,7 +125,7 @@ end = struct let data = Pbrt.Encoder.to_string encoder in let url = let url = config.Config.url in - if String.ends_with url ~suffix:"/" then + if url <> "" && String.get url (String.length url - 1) = '/' then String.sub url 0 (String.length url - 1) else url