fixing handling of http:// calls in the Extras URL

This commit is contained in:
Colin Kuskie 2007-12-04 21:25:32 +00:00
parent 21658d2ffd
commit 72906e27fb
3 changed files with 27 additions and 11 deletions

View file

@ -11,6 +11,8 @@
7.4.17
- fix: double width characters encoded incorrectly in Collaboration RSS feed
- fix: ExtrasUrl in conf http:// stripping / from URL (perlDreamer Consulting, LLC.)
http://www.plainblack.com/bugs/tracker/extrasurl-in-conf-http/-stripping-/-from-url
7.4.16
- fix: Event End Time Missing (perlDreamer Consulting, LLC.)

View file

@ -130,16 +130,18 @@ Combinds the base extrasURL defined in the config file with a specfied path.
=head3 path
The path to the thing in the extras folder that you're referencing. Note that the leading / is not necessary. Multiple consecutive slashes will be replaced with a single slash.
The path to the thing in the extras folder that you're
referencing. Note that the leading / is not necessary. Multiple
consecutive slashes in the path part of the URL will be replaced with a single slash.
=cut
sub extras {
my $self = shift;
my $path = shift;
my $url = $self->session->config->get("extrasURL").'/'.$path;
$url =~ s!/+!/!g;
return $url;
my $self = shift;
my $path = shift;
my $url = $self->session->config->get("extrasURL").'/'.$path;
$url =~ s$(?<!^http:)/{2,}$/$g;
return $url;
}
#-------------------------------------------------------------------

View file

@ -51,7 +51,7 @@ my @getRefererUrlTests = (
);
use Test::More;
plan tests => 56 + scalar(@getRefererUrlTests);
plan tests => 58 + scalar(@getRefererUrlTests);
my $session = WebGUI::Test->session;
@ -278,10 +278,21 @@ is($session->url->makeAbsolute('page1'), '/page1', 'makeAbsolute: default baseUr
#
#######################################
is($session->url->extras, $session->config->get('extrasURL').'/', 'extras method returns URL to extras with a trailing slash');
is($session->url->extras('foo.html'), join('/', $session->config->get('extrasURL'),'foo.html'), 'extras method appends to the extras url');
is($session->url->extras('/foo.html'), join('/', $session->config->get('extrasURL'),'foo.html'), 'extras method removes extra slashes');
is($session->url->extras('/dir1//foo.html'), join('/', $session->config->get('extrasURL'),'dir1/foo.html'), 'extras method removes extra slashes anywhere');
my $origExtras = $session->config->get('extrasURL');
my $extras = $origExtras;
is($session->url->extras, $extras.'/', 'extras method returns URL to extras with a trailing slash');
is($session->url->extras('foo.html'), join('/', $extras,'foo.html'), 'extras method appends to the extras url');
is($session->url->extras('/foo.html'), join('/', $extras,'foo.html'), 'extras method removes extra slashes');
is($session->url->extras('/dir1//foo.html'), join('/', $extras,'dir1/foo.html'), 'extras method removes extra slashes anywhere');
$extras = 'http://mydomain.com/';
$session->config->set('extrasURL', $extras);
is($session->url->extras('/foo.html'), join('', $extras,'foo.html'), 'extras method removes extra slashes');
is($session->url->extras('/dir1//foo.html'), join('', $extras,'dir1/foo.html'), 'extras method removes extra slashes anywhere');
$session->config->set('extrasURL', $origExtras);
#######################################
#
@ -387,6 +398,7 @@ END { ##Always clean-up
$session->setting->set('hostToUse', $setting_hostToUse);
$session->setting->set('preventProxyCache', $preventProxyCache);
$session->config->set('gateway', $gateway);
$session->config->set('extrasURL', $origExtras);
if ($config_port) {
$session->config->set($config_port);