Closed oalders closed 3 years ago
Yeah, this always annoys me too.
Maybe something like:
sub _agent {
my $class = ref($_[0]) || $_[0];
my $version = $class->VERSION;
if (not defined $version) {
$class = __PACKAGE__;
$version = $class->VERSION;
}
(my $default_agent = $class) =~ s{::}{-}g;
return $default_agent . "/" . $version;
}
This is from a test in
MetaCPAN::Client
.When the test using this class is run:
The code in
HTTP::Tiny
:Obviously the test class can add a version to
TrapUA
in order to get around this (and this is what I'll be doing). I just wanted to establish if it's reasonable for_agent
to use a default version in the case that$class->VERSION
is not defined. I'm happy to put a pull request together if this is useful.