use std::path::{Path, PathBuf};
use super::{NormalizedUrl, RelPagePath};
pub(crate) struct AbsPagePath(PathBuf);
impl AbsPagePath {
pub(crate) fn from_raw_url(root: &Path, url: &str) -> Option<Self> {
let url = NormalizedUrl::try_from(url).ok()?;
Some(Self::from_normalized_url(root, &url))
}
pub(crate) fn from_normalized_url(root: &Path, url: &NormalizedUrl<'_>) -> Self {
let rel = RelPagePath::from(url);
Self(root.join(rel.as_ref()))
}
}
impl AsRef<Path> for AbsPagePath {
fn as_ref(&self) -> &Path {
self.0.as_ref()
}
}