[Catalyst-commits] r8085 - in Catalyst-Plugin-SmartURI/1.000/trunk:
. lib/Catalyst/Plugin
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Sun Jul 6 22:21:26 BST 2008
Author: caelum
Date: 2008-07-06 22:21:26 +0100 (Sun, 06 Jul 2008)
New Revision: 8085
Modified:
Catalyst-Plugin-SmartURI/1.000/trunk/Changes
Catalyst-Plugin-SmartURI/1.000/trunk/META.yml
Catalyst-Plugin-SmartURI/1.000/trunk/lib/Catalyst/Plugin/SmartURI.pm
Log:
SmartURI: fix POD, improve referer
Modified: Catalyst-Plugin-SmartURI/1.000/trunk/Changes
===================================================================
--- Catalyst-Plugin-SmartURI/1.000/trunk/Changes 2008-07-05 20:21:50 UTC (rev 8084)
+++ Catalyst-Plugin-SmartURI/1.000/trunk/Changes 2008-07-06 21:21:26 UTC (rev 8085)
@@ -24,3 +24,6 @@
0.025 2008-06-28 08:33:57
Fucked up the pod for SYNOPSIS...
+
+0.027 2008-07-06 14:17:12
+ Improved request class, better Host header parsing, fixed POD.
Modified: Catalyst-Plugin-SmartURI/1.000/trunk/META.yml
===================================================================
--- Catalyst-Plugin-SmartURI/1.000/trunk/META.yml 2008-07-05 20:21:50 UTC (rev 8084)
+++ Catalyst-Plugin-SmartURI/1.000/trunk/META.yml 2008-07-06 21:21:26 UTC (rev 8085)
@@ -22,4 +22,4 @@
Task::Weaken: 0
URI::SmartURI: 0
parent: 0
-version: 0.026
+version: 0.027
Modified: Catalyst-Plugin-SmartURI/1.000/trunk/lib/Catalyst/Plugin/SmartURI.pm
===================================================================
--- Catalyst-Plugin-SmartURI/1.000/trunk/lib/Catalyst/Plugin/SmartURI.pm 2008-07-05 20:21:50 UTC (rev 8084)
+++ Catalyst-Plugin-SmartURI/1.000/trunk/lib/Catalyst/Plugin/SmartURI.pm 2008-07-06 21:21:26 UTC (rev 8085)
@@ -21,11 +21,11 @@
=head1 VERSION
-Version 0.026
+Version 0.027
=cut
-our $VERSION = '0.026';
+our $VERSION = '0.027';
=head1 SYNOPSIS
@@ -67,17 +67,28 @@
=head1 METHODS
=head2 $c->uri_for
+
=head2 $c->req->uri_with
Returns a $c->uri_class object (L<URI::SmartURI> by default) in the configured
$c->uri_disposition.
=head2 $c->req->uri
-=head2 $c->req->referer
Returns a $c->uri_class object. If the context hasn't been prepared yet, uses
the configured value for uri_class.
+$c->req->uri->relative will be relative to $c->req->base.
+
+=head2 $c->req->referer
+
+Returns a $c->uri_class object for the referer (or configured uri_class if
+there's no context) with reference set to $c->req->uri if it comes from
+$c->req->base.
+
+In other words, if referer is your web server, you can do
+$c->req->referer->relative and it will do the right thing.
+
=head1 CONFIGURATION
In myapp.conf:
@@ -165,8 +176,15 @@
my $req = shift;
my $uri_class = $context ? $context->uri_class : $conf_uri_class;
+ my $referer = $req->next::method(@_) || '';
+ my $base = $req->base;
+ my $uri = $req->uri;
- $uri_class->new($req->next::method(@_))
+ if ($referer =~ /^$base/) {
+ return $uri_class->new($referer, { reference => $uri })
+ } else {
+ return $uri_class->new($referer);
+ }
}
}
More information about the Catalyst-commits
mailing list