[MKDoc-dev] self_uri stripping port number

Charlie Garrison garrison at zeta.org.au
Sat Sep 25 18:02:23 BST 2004


Good morning,

I found that self_uri in MKDoc::Core::Request is a bit too agressive with
stripping out port numbers. The regex was (from what I can read) stripping any
port numbers starting with 80, not just port 80. I modified it back to the
v1.6 behaviour so that port 8080 remains in the url.

sub self_uri
{
    my $self = shift;
    my %opt  = map { "-" . $_ => 1 } ( @_, qw /path_info query/ );
    $opt{relative}  ||= 0;

    my $url  = $self->url (\%opt);
#     $url =~ s/(.*?\:\/\/(?:.*?\@)?)(.*):80\d?\d?(?!\d)(.*)/$1$2$3/
#         if ($url =~ /(.*?\:\/\/(?:.*?\@)?)(.*):80\d?\d?(?!\d)(.*)/);
    $url =~ s/(.*?\:\/\/(?:.*?\@)?)(.*):80(?!\d)(.*)/$1$2$3/
        if ($url =~ /(.*?\:\/\/(?:.*?\@)?)(.*):80(?!\d)(.*)/);

    return $url;
}


But that brings up another issue, and that is a more flexible way of
configuring which port number(s) should be stripped from the url. Right now I
want :8080 as part of the url because I haven't configured my frontend apache
to proxy requests for my mkdoc test server. But after I've made that config,
then I will want :8080 stripped from the url. And when I setup mkdoc on the
production server, the port number will be something else again. Of course
changing the sub for each server is not satisfactory.

%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. 

Will the MKDoc::Core modules become part of the cvs repository? Or should
submissions for those modules always be sent via the mailing list?

Thanks,
Charlie

-- 
   Charlie Garrison  <garrison at zeta.org.au>
   PO Box 141, Windsor, NSW 2756, Australia


More information about the MKDoc-dev mailing list