Skip to content

Commit

Permalink
Added root_dir() as synonym to rootdir() - that's the naming that CHI…
Browse files Browse the repository at this point in the history
… uses
  • Loading branch information
nigelhorne committed Jan 3, 2024
1 parent 09d14a0 commit ee44c63
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Revision history for CGI-Info
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

0.78 Fri Oct 6 13:59:51 EDT 2023
Set HTTP status to 403 on HTTP_USER_AGENT SQL injection attack
Expand Down
18 changes: 17 additions & 1 deletion lib/CGI/Info.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,22 @@ sub rootdir {
return $script_name;
}

=head2 root_dir
Synonym of rootdir(), for compatability with L<CHI>.
=cut

sub root_dir
{
if($_[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 Expand Up @@ -1810,7 +1826,7 @@ L<http://deps.cpantesters.org/?module=CGI::Info>
=head1 LICENSE AND COPYRIGHT
Copyright 2010-2023 Nigel Horne.
Copyright 2010-2024 Nigel Horne.
This program is released under the following licence: GPL2
Expand Down
4 changes: 3 additions & 1 deletion 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 => 25;
use Test::Most tests => 27;
use File::Spec;
use Test::NoWarnings;

Expand All @@ -25,7 +25,9 @@ ROOTDIR: {
}

ok(CGI::Info->rootdir() eq $dir);
ok(CGI::Info->root_dir() eq $dir);
ok(CGI::Info::rootdir() eq $dir);
ok(CGI::Info::root_dir() eq $dir);

$ENV{'DOCUMENT_ROOT'} = File::Spec->catdir(File::Spec->tmpdir(), 'xyzzy');
$dir = CGI::Info->rootdir();
Expand Down

0 comments on commit ee44c63

Please sign in to comment.