From 3cb3994cd2005231f8cc60ce02c55762a7b293f3 Mon Sep 17 00:00:00 2001 From: Quentin Date: Tue, 10 Nov 2020 17:05:10 +0100 Subject: [PATCH] Add documentation to host_to_bucket --- src/web/web_server.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/web/web_server.rs b/src/web/web_server.rs index 73aa6648..2440857d 100644 --- a/src/web/web_server.rs +++ b/src/web/web_server.rs @@ -93,6 +93,12 @@ fn authority_to_host(authority: &str) -> Result<&str, Error> { } } +/// Host to bucket +/// +/// Convert a host, like "bucket.garage-site.tld" or "john.doe.com" +/// to the corresponding bucket, resp. "bucket" and "john.doe.com" +/// considering that ".garage-site.tld" is the "root domain". +/// This behavior has been chosen to follow AWS S3 semantic. fn host_to_bucket<'a>(host: &'a str, root: &str) -> &'a str { if root.len() >= host.len() || !host.ends_with(root) { return host;