Skip Menu |

This queue is for tickets about the URI-FromHash CPAN distribution.

Report information
The Basics
Id: 31352
Status: resolved
Priority: 0/
Queue: URI-FromHash

People
Owner: Nobody in particular
Requestors: dave.s.doyle [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: 0.03



Subject: path by arrayref (patch enclosed)
Hello, I was actually looking for a module that would let me assemble the path portion of a URI from an array and ensure that separating slashes were taken care of (and don't repeat). Your module, while great for avoiding all the URI method calls, doesn't do that for me. I've included a patch that would allow the path to be passed as an arrayref as well as a scalar. If arrayref is used, the path is assembled by joining them and then removing dupe slashes. It's a small thing but I find it gives me a little more flexibility. I'd love for this (or something like it... no doubt better coded than my example) to become a part of the module but if you wanted to be strictly a wrapper for the URI method or this doesn't jive with how you want it to work, I understand of course. It's your module after all. But it can't hurt to ask! Thanks, Dave Doyle
Subject: FromHash.pm.patch
*** FromHash.pm Mon Dec 10 16:28:57 2007 --- FromHash-modified.pm Mon Dec 10 16:28:13 2007 *************** *** 10,16 **** $VERSION = '0.02'; @EXPORT_OK = qw( uri uri_object ); ! use Params::Validate qw( validate SCALAR HASHREF ); use URI; use URI::QueryParam; --- 10,16 ---- $VERSION = '0.02'; @EXPORT_OK = qw( uri uri_object ); ! use Params::Validate qw( validate SCALAR HASHREF ARRAYREF ); use URI; use URI::QueryParam; *************** *** 22,28 **** password => { type => SCALAR, default => '' }, host => { type => SCALAR, optional => 1 }, port => { type => SCALAR, optional => 1 }, ! path => { type => SCALAR, optional => 1 }, query => { type => HASHREF, default => {} }, fragment => { type => SCALAR, optional => 1 }, ); --- 22,28 ---- password => { type => SCALAR, default => '' }, host => { type => SCALAR, optional => 1 }, port => { type => SCALAR, optional => 1 }, ! path => { type => SCALAR | ARRAYREF, optional => 1 }, query => { type => HASHREF, default => {} }, fragment => { type => SCALAR, optional => 1 }, ); *************** *** 56,64 **** if grep { defined && length } $p{host}; $uri->port( $p{port} ) if grep { defined && length } $p{port}; ! ! $uri->path( $p{path} ) ! if grep { defined && length } $p{path}; while ( my ( $k, $v ) = each %{ $p{query} } ) { --- 56,69 ---- if grep { defined && length } $p{host}; $uri->port( $p{port} ) if grep { defined && length } $p{port}; ! ! if ( defined $p{path} ) { ! if ( ref $p{path} eq 'ARRAY' ) { ! $p{path} = join '/', @{$p{path}}; ! $p{path} =~ s{//+}{/}g; ! } ! $uri->path( $p{path} ) if length $p{path}; ! } while ( my ( $k, $v ) = each %{ $p{query} } ) {