Support website publishing #7

Merged
lx merged 61 commits from feature/website into master 2021-01-15 16:49:51 +00:00
Showing only changes of commit ab62c59acb - Show all commits

View file

@ -73,9 +73,12 @@ fn authority_to_host(authority: &str) -> Result<&str, Error> {
let split = match iter.next() { let split = match iter.next() {
Some((_, '[')) => { Some((_, '[')) => {
let mut niter = iter.skip_while(|(_, c)| c != &']'); let mut niter = iter.skip_while(|(_, c)| c != &']');
niter.next().ok_or(Error::BadRequest(format!("Authority {} has an illegal format", authority)))?; niter.next().ok_or(Error::BadRequest(format!(
"Authority {} has an illegal format",
authority
)))?;
niter.next() niter.next()
}, }
Some((_, _)) => iter.skip_while(|(_, c)| c != &':').next(), Some((_, _)) => iter.skip_while(|(_, c)| c != &':').next(),
None => return Err(Error::BadRequest(format!("Authority is empty"))), None => return Err(Error::BadRequest(format!("Authority is empty"))),
}; };
@ -83,11 +86,13 @@ fn authority_to_host(authority: &str) -> Result<&str, Error> {
match split { match split {
Some((i, ':')) => Ok(&authority[..i]), Some((i, ':')) => Ok(&authority[..i]),
None => Ok(authority), None => Ok(authority),
Some((_, _)) => Err(Error::BadRequest(format!("Authority {} has an illegal format", authority))), Some((_, _)) => Err(Error::BadRequest(format!(
"Authority {} has an illegal format",
authority
))),
quentin marked this conversation as resolved
Review

Rewrite as only two cases:

BucketState::Present(params) if params.website.get() => Ok(()),
_ => Err(Error::NotFound),
Rewrite as only two cases: ``` BucketState::Present(params) if params.website.get() => Ok(()), _ => Err(Error::NotFound), ```
} }
} }
fn host_to_bucket<'a>(host: &'a str, root: &str) -> &'a str { fn host_to_bucket<'a>(host: &'a str, root: &str) -> &'a str {
if root.len() >= host.len() || !host.ends_with(root) { if root.len() >= host.len() || !host.ends_with(root) {
return host; return host;