[MKDoc-dev] self_uri stripping port number
Charlie Garrison
garrison at zeta.org.au
Sun Sep 26 10:49:04 BST 2004
Good evening,
On 26/9/04 at 1:22 PM +1000, Charlie Garrison <garrison at zeta.org.au> wrote:
>>> %ENV is used for many other config options. Is this another one to be
>>> configured that way? What about multiple port numbers? Should the
>>> variable (eg $ENV{MKD__PORT_TO_STRIP}) be something like:
>>>
>>> MKD__PORT_TO_STRIP "80,8080,8081"
>>>
>>> or assign the actual regex snippet:
>>>
>>> MKD__PORT_TO_STRIP ":80\d?\d?"
>>>
>>> The first is less prone to user error (in the config file) but is not as
>>> efficient. I prefer the second option. Maybe both are appropriate using
>>> MKD__PORT_TO_STRIP and MKD__PORT_TO_STRIP_REGEX.
>>
>>That sounds like a good plan to me :-)
>
>I'll add that to my todo list.
I have changed the 'url' sub in MKDoc-Core/lib/MKDoc/Core/Request.pm:
sub url
{
my $self = shift;
my $url = $self->SUPER::url (@_);
my $port_strip = $ENV{MKD__URL_PORT_STRIP} || ''; #'80,8080'
my $port_strip_regex = $ENV{MKD__URL_PORT_STRIP_REGEX} || ''; #'80\d*';
$port_strip =~ tr/,/|/; # change commas to regex alternator
my $port_strip_str = $port_strip || $port_strip_regex || '80';
# assumes url always has a port specifier
$url =~ s/(.*?\:\/\/(?:.*?\@)?)(.*):(?:${port_strip_str})(?!\d)(.*)/$1$2$3/
if ($url =~ /(.*?\:\/\/(?:.*?\@)?)(.*):${port_strip_str}(?!\d)(.*)/);
return $url;
}
And I have added the following lines to sites/example.com.au/httpd/httpd-env.conf (I'm
not sure where the original used during site setup/install is located):
# Uncomment if you want the following port numbers (comma separated) to be stripped from URLs.
# SetEnv MKD__URL_PORT_STRIP "80,8080"
# Uncomment if you want port numbers matching the following regex to be stripped from URLs.
# SetEnv MKD__URL_PORT_STRIP_REGEX "80\d*"
Charlie
--
Charlie Garrison <garrison at zeta.org.au>
PO Box 141, Windsor, NSW 2756, Australia
More information about the MKDoc-dev
mailing list