Add URL parsing.
This commit is contained in:
@@ -16,6 +16,7 @@ pub(crate) enum CustomError {
|
||||
DusterCompile(duster::renderer::CompileError),
|
||||
DusterRender(duster::renderer::RenderError),
|
||||
PathStripPrefix(std::path::StripPrefixError),
|
||||
UrlParseError(url::ParseError),
|
||||
}
|
||||
|
||||
impl From<std::io::Error> for CustomError {
|
||||
@@ -95,3 +96,9 @@ impl From<std::path::StripPrefixError> for CustomError {
|
||||
CustomError::PathStripPrefix(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<url::ParseError> for CustomError {
|
||||
fn from(value: url::ParseError) -> Self {
|
||||
CustomError::UrlParseError(value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use organic::types::StandardProperties;
|
||||
use url::Url;
|
||||
|
||||
use super::macros::intermediate;
|
||||
|
||||
@@ -46,6 +47,7 @@ pub(crate) enum LinkTarget {
|
||||
impl LinkTarget {
|
||||
pub(crate) fn from_string<S: AsRef<str>>(input: S) -> Result<LinkTarget, CustomError> {
|
||||
fn impl_from_string(input: &str) -> Result<LinkTarget, CustomError> {
|
||||
let parsed = Url::parse(input)?;
|
||||
Ok(LinkTarget::Raw(input.to_owned()))
|
||||
}
|
||||
impl_from_string(input.as_ref())
|
||||
|
||||
Reference in New Issue
Block a user