[librsvg: 3/10] iri: use Fragment directly




commit d0b565bf175dba7b4fed7882575b473996fcbe75
Author: Paolo Borelli <pborelli gnome org>
Date:   Sat Dec 12 14:58:58 2020 +0100

    iri: use Fragment directly
    
    Since PlainUrl is not valid, just let Fragment::parse raise the
    corresponding error

 src/iri.rs | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
---
diff --git a/src/iri.rs b/src/iri.rs
index 45d4dbd4..c461b078 100644
--- a/src/iri.rs
+++ b/src/iri.rs
@@ -4,7 +4,7 @@ use cssparser::Parser;
 
 use crate::error::*;
 use crate::parsers::Parse;
-use crate::url_resolver::{Fragment, Href};
+use crate::url_resolver::Fragment;
 
 /// Used where style properties take a funciri or "none"
 ///
@@ -43,18 +43,11 @@ impl Parse for IRI {
             Ok(IRI::None)
         } else {
             let loc = parser.current_source_location();
-
             let url = parser.expect_url()?;
+            let fragment =
+                Fragment::parse(&url).map_err(|e| loc.new_custom_error(ValueErrorKind::from(e)))?;
 
-            let href =
-                Href::parse(&url).map_err(|e| loc.new_custom_error(ValueErrorKind::from(e)))?;
-
-            match href {
-                Href::PlainUrl(_) => Err(loc.new_custom_error(ValueErrorKind::parse_error(
-                    "href requires a fragment identifier",
-                ))),
-                Href::WithFragment(f) => Ok(IRI::Resource(f)),
-            }
+            Ok(IRI::Resource(fragment))
         }
     }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]