From ee44c63479307a3b055884addff3e0fa5b2e0d31 Mon Sep 17 00:00:00 2001 From: Nigel Horne Date: Wed, 3 Jan 2024 11:39:12 -0500 Subject: [PATCH] Added root_dir() as synonym to rootdir() - that's the naming that CHI uses --- Changes | 1 + lib/CGI/Info.pm | 18 +++++++++++++++++- t/rootdir.t | 4 +++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Changes b/Changes index c2a8e97..64146bd 100644 --- a/Changes +++ b/Changes @@ -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 diff --git a/lib/CGI/Info.pm b/lib/CGI/Info.pm index 3ca2fb7..dc48d75 100644 --- a/lib/CGI/Info.pm +++ b/lib/CGI/Info.pm @@ -1291,6 +1291,22 @@ sub rootdir { return $script_name; } +=head2 root_dir + +Synonym of rootdir(), for compatability with L. + +=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. @@ -1810,7 +1826,7 @@ L =head1 LICENSE AND COPYRIGHT -Copyright 2010-2023 Nigel Horne. +Copyright 2010-2024 Nigel Horne. This program is released under the following licence: GPL2 diff --git a/t/rootdir.t b/t/rootdir.t index 4c5c438..5433739 100644 --- a/t/rootdir.t +++ b/t/rootdir.t @@ -2,7 +2,7 @@ use strict; use warnings; -use Test::Most tests => 25; +use Test::Most tests => 27; use File::Spec; use Test::NoWarnings; @@ -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();