@@ -553,8 +553,8 @@ impl UUri {
553
553
self . eq ( & UUri :: default ( ) )
554
554
}
555
555
556
- /// Check if an `UUri` is remote, by comparing authority fields. UUris with empty authority are
557
- /// considered to be local.
556
+ /// Check if an `UUri` is remote, by comparing authority fields.
557
+ /// UUris with empty authority are considered to be local.
558
558
///
559
559
/// # Returns
560
560
///
@@ -568,21 +568,49 @@ impl UUri {
568
568
///
569
569
/// let authority_a = UUri::from_str("up://Authority.A/100A/1/0").unwrap();
570
570
/// let authority_b = UUri::from_str("up://Authority.B/200B/2/20").unwrap();
571
- /// assert!(authority_a.is_remote_authority (&authority_b));
571
+ /// assert!(authority_a.is_remote (&authority_b));
572
572
///
573
573
/// let authority_local = UUri::from_str("up:///100A/1/0").unwrap();
574
- /// assert!(!authority_local.is_remote_authority (&authority_a));
574
+ /// assert!(!authority_local.is_remote (&authority_a));
575
575
///
576
576
/// let authority_wildcard = UUri::from_str("up://*/100A/1/0").unwrap();
577
- /// assert!(!authority_wildcard.is_remote_authority (&authority_a));
578
- /// assert!(!authority_a.is_remote_authority (&authority_wildcard));
579
- /// assert!(!authority_wildcard.is_remote_authority (&authority_wildcard));
577
+ /// assert!(!authority_wildcard.is_remote (&authority_a));
578
+ /// assert!(!authority_a.is_remote (&authority_wildcard));
579
+ /// assert!(!authority_wildcard.is_remote (&authority_wildcard));
580
580
/// ````
581
- pub fn is_remote_authority ( & self , other_uri : & UUri ) -> bool {
582
- !self . authority_name . is_empty ( )
583
- && self . authority_name != WILDCARD_AUTHORITY
584
- && other_uri. authority_name != WILDCARD_AUTHORITY
585
- && self . authority_name != other_uri. authority_name
581
+ pub fn is_remote ( & self , other_uri : & UUri ) -> bool {
582
+ self . is_remote_authority ( & other_uri. authority_name )
583
+ }
584
+
585
+ /// Check if an authority is remote compared to the authority field of the UUri.
586
+ /// Empty authorities are considered to be local.
587
+ ///
588
+ /// # Returns
589
+ ///
590
+ /// 'true' if authority is a different than `Self.authority_name`, `false` otherwise.
591
+ ///
592
+ /// # Examples
593
+ ///
594
+ /// ```rust
595
+ /// use std::str::FromStr;
596
+ /// use up_rust::UUri;
597
+ ///
598
+ /// let authority_a = UUri::from_str("up://Authority.A/100A/1/0").unwrap();
599
+ /// let authority_b = "Authority.B".to_string();
600
+ /// assert!(authority_a.is_remote_authority(&authority_b));
601
+ ///
602
+ /// let authority_local = "".to_string();
603
+ /// assert!(!authority_a.is_remote_authority(&authority_local));
604
+ ///
605
+ /// let authority_wildcard = "*".to_string();
606
+ /// assert!(!authority_a.is_remote_authority(&authority_wildcard));
607
+ /// ```
608
+ pub fn is_remote_authority ( & self , authority : & String ) -> bool {
609
+ !authority. is_empty ( )
610
+ && !self . authority_name . is_empty ( )
611
+ && !self . has_wildcard_authority ( )
612
+ && authority != WILDCARD_AUTHORITY
613
+ && self . authority_name != * authority
586
614
}
587
615
588
616
/// Checks if this UUri has an empty authority name.
0 commit comments