File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,9 +14,13 @@ license.workspace = true
1414repository.workspace = true
1515rust-version.workspace = true
1616
17+ [features ]
18+ default = [" fluent-uri" ]
19+ fluent-uri = [" dep:fluent-uri" ]
20+
1721[dependencies ]
1822base64 = " 0.22.1"
19- fluent-uri = " 0.4.1"
23+ fluent-uri = { version = " 0.4.1" , optional = true }
2024indexmap = " 2.2.2"
2125once_cell = " 1.18.0"
2226ordered-float = { version = " 5.0.0" , default-features = false }
Original file line number Diff line number Diff line change 1818
1919use std:: { convert:: TryFrom , str:: FromStr } ;
2020
21- use fluent_uri:: UriRef as Url ;
2221use purl:: { GenericPurl , GenericPurlBuilder } ;
2322use thiserror:: Error ;
2423
@@ -64,8 +63,9 @@ impl AsRef<str> for Purl {
6463 }
6564}
6665
67- pub fn validate_uri ( uri : & Uri ) -> Result < ( ) , ValidationError > {
68- if Url :: parse ( uri. 0 . as_str ( ) ) . is_err ( ) {
66+ pub fn validate_uri ( _uri : & Uri ) -> Result < ( ) , ValidationError > {
67+ #[ cfg( feature = "fluent-uri" ) ]
68+ if fluent_uri:: UriRef :: parse ( _uri. 0 . as_str ( ) ) . is_err ( ) {
6969 return Err ( ValidationError :: new ( "Uri does not conform to RFC 3986" ) ) ;
7070 }
7171 Ok ( ( ) )
@@ -88,12 +88,13 @@ impl TryFrom<String> for Uri {
8888 type Error = UriError ;
8989
9090 fn try_from ( value : String ) -> Result < Self , Self :: Error > {
91- match Url :: parse ( value . as_str ( ) ) {
92- Ok ( _ ) => Ok ( Uri ( value) ) ,
93- Err ( _ ) => Err ( UriError :: InvalidUri (
91+ # [ cfg ( feature = "fluent-uri" ) ]
92+ if fluent_uri :: UriRef :: parse ( value. as_str ( ) ) . is_err ( ) {
93+ return Err ( UriError :: InvalidUri (
9494 "Uri does not conform to RFC 3986" . to_string ( ) ,
95- ) ) ,
95+ ) ) ;
9696 }
97+ Ok ( Uri ( value) )
9798 }
9899}
99100
You can’t perform that action at this time.
0 commit comments