use core::fmt; use super::{Dir, Query, VPath}; /// This Dir exists to serve as a compatibility layer for very old links that end with .html. pub struct HtmlCanonicalize { inner: T, } impl HtmlCanonicalize { pub fn new(inner: T) -> Self { Self { inner } } } impl Dir for HtmlCanonicalize where T: Dir, { fn query(&self, path: &VPath, query: &mut Query) { let mut path = path.to_owned(); if path.extension() == Some("html") { path.set_extension(""); } self.inner.query(&path, query); } } impl fmt::Debug for HtmlCanonicalize where T: fmt::Debug, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "HtmlCanonicalize({:?})", self.inner) } }