Subject: | [PATCH] Fixing coercion from HashRef |
Hello,
the attached patch tries to fix that coercion from a hash reference
did not return an URI object.
Thank you for your time and consideration.
Regards,
--
MORIYA Masaki, alias Gardejo
Subject: | fix-coerce-from-hashref.patch |
diff --git a/lib/MooseX/Types/URI.pm b/lib/MooseX/Types/URI.pm
index 7507b63..ac338ae 100644
--- a/lib/MooseX/Types/URI.pm
+++ b/lib/MooseX/Types/URI.pm
@@ -13,7 +13,7 @@ use URI;
use URI::file;
use URI::data;
use URI::WithBase;
-use URI::FromHash qw(uri);
+use URI::FromHash qw(uri_object);
use Moose::Util::TypeConstraints;
@@ -48,7 +48,7 @@ coerce( Uri,
from File , via { URI::file->new($_) },
from Dir , via { URI::file->new($_) },
from ScalarRef , via { my $u = URI->new("data:"); $u->data($$_); $u },
- from HashRef , via { uri(%$_) },
+ from HashRef , via { uri_object(%$_) },
);
class_type FileUri, { class => "URI::file", parent => $uri };
diff --git a/t/basic.t b/t/basic.t
index 35ceb28..5ef7c79 100644
--- a/t/basic.t
+++ b/t/basic.t
@@ -90,6 +90,10 @@ isa_ok( to_Uri("foo"), "URI" );
is( to_Uri("foo")->path, "foo", "URI" );
is( to_Uri("foo")->scheme, undef, "URI" );
+isa_ok( to_Uri({path => 'foo'}), "URI" );
+is( to_Uri({path => 'foo'})->path, "foo", "URI from HashRef" );
+is( to_Uri({path => 'foo'})->scheme, undef, "URI from HashRef" );
+
isa_ok( to_FileUri("foo"), "URI::file" );
is( to_FileUri("foo")->file, "foo", "filename" );