Skip to content

Commit 36beef2

Browse files
committed
add may_be_uri
1 parent 3f2d927 commit 36beef2

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

lib/Net/RDAP/JCard/Property.pm

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package Net::RDAP::JCard::Property;
2-
use List::Util qw(pairmap);
2+
use List::Util qw(any);
33
use strict;
44
use warnings;
55

6+
my @URI_TYPES = qw(source logo member related sound uid uri caladruri caluri contact-uri socialprofile impp url email);
7+
68
=pod
79
810
=head1 NAME
@@ -118,7 +120,14 @@ Returns a string containing the property value type. See the L<vCard Value Data
118120
Types|https://www.iana.org/assignments/vcard-elements/vcard-elements.xhtml#value-data-types>
119121
IANA registry for a list of possible values.
120122
121-
This method will always return the value type in UPPERCASE.
123+
This method will always return the value type in lowercase.
124+
125+
=head2 URIness
126+
127+
Some properties may be URIs, depending on the property type and value type. The
128+
C<may_be_uri()> method will return a true value if the property value may be a
129+
URI (either because of the specification of its type, or the value of its
130+
C<value_type()>.
122131
123132
=head2 PROPERTY VALUE
124133
@@ -156,6 +165,19 @@ sub TO_JSON {
156165
];
157166
}
158167

168+
sub may_be_uri {
169+
my $self = shift;
170+
if (q{uri} eq $self->value_type) {
171+
return 1;
172+
173+
} elsif (any { $_ eq $self->type } @URI_TYPES) {
174+
return 1;
175+
176+
}
177+
178+
return undef;
179+
}
180+
159181
=pod
160182
161183
=head1 COPYRIGHT

0 commit comments

Comments
 (0)