Skip to content

Commit

Permalink
Added document_root() as a synonym to rootdir()
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelhorne committed Jan 16, 2024
1 parent f806d8e commit e53b0be
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
7 changes: 6 additions & 1 deletion Changes
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
Revision history for CGI-Info

0.80
Added document_root() as a synonym to rootdir()
For compatability with Apache

0.79 Wed Jan 3 14:25:42 EST 2024
Better arg count checking
Mark techiaith.cymru as a robot
Facebook FBCLID can have "--" which can cause false positives
Mark ChatGPT as a search engine
Added root_dir() as synonym to rootdir() - that's the naming that CHI uses
Added root_dir() as synonym to rootdir()
That's the naming that CHI uses

0.78 Fri Oct 6 13:59:51 EDT 2023
Set HTTP status to 403 on HTTP_USER_AGENT SQL injection attack
Expand Down
16 changes: 16 additions & 0 deletions lib/CGI/Info.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,22 @@ sub root_dir
return __PACKAGE__->rootdir(@_);
}

=head2 document_root
Synonym of rootdir(), for compatibility with Apache.
=cut

sub document_root
{
if($_[0] && ref($_[0])) {
my $self = shift;

return $self->rootdir(@_);
}
return __PACKAGE__->rootdir(@_);
}

=head2 logdir
Gets and sets the name of a directory that you can use to store logs in.
Expand Down
8 changes: 5 additions & 3 deletions t/rootdir.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use strict;
use warnings;
use Test::Most tests => 27;
use Test::Most tests => 29;
use File::Spec;
use Test::NoWarnings;

Expand All @@ -28,6 +28,8 @@ ROOTDIR: {
ok(CGI::Info->root_dir() eq $dir);
ok(CGI::Info::rootdir() eq $dir);
ok(CGI::Info::root_dir() eq $dir);
ok(CGI::Info::document_root() eq $dir);
ok(CGI::Info::document_root() eq $dir);

$ENV{'DOCUMENT_ROOT'} = File::Spec->catdir(File::Spec->tmpdir(), 'xyzzy');
$dir = CGI::Info->rootdir();
Expand All @@ -37,7 +39,7 @@ ROOTDIR: {
delete $ENV{'C_DOCUMENT_ROOT'};
$ENV{'DOCUMENT_ROOT'} = File::Spec->catdir(File::Spec->tmpdir(), 'xyzzy');
$i = new_ok('CGI::Info');
$dir = $i->rootdir();
$dir = $i->document_root();
ok(-r $dir);
ok(-d $dir);

Expand Down Expand Up @@ -66,7 +68,7 @@ ROOTDIR: {
ok(-d $dir);

$ENV{'DOCUMENT_ROOT'} = File::Spec->catdir(File::Spec->tmpdir());
$dir = $i->rootdir();
$dir = $i->root_dir();
ok($dir eq File::Spec->catdir(File::Spec->tmpdir()));
ok(-r $dir);
ok(-d $dir);
Expand Down

0 comments on commit e53b0be

Please sign in to comment.