Index: t/007_default_target.t =================================================================== --- t/007_default_target.t (.../trunk) (revision 0) +++ t/007_default_target.t (.../branches/fix-empty-target-take-2) (revision 14) @@ -0,0 +1,52 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More tests => 14; +use Test::Exception; + +package main; + +BEGIN { + use_ok('CGI::Application::Server'); +} + +=pod + +This could probably use some more tests, but it +is good enough for now. + +=cut + +my $server = CGI::Application::Server->new(); +isa_ok($server, 'CGI::Application::Server'); +isa_ok($server, 'HTTP::Server::Simple'); + +$server->entry_points({ + '/' => 'TopLevel', + '/foo' => 'Foo', +}); + +foreach my $uri (qw( + /foo + /foo?say=hello + /foo/bling/bar + /foo/?bar=baz + /foo/barr + )) { + is($server->is_valid_entry_point($uri), 'Foo', '... got Foo where we expected'); +} + +foreach my $uri (qw( + / + /fooo + /fooo/ + /food?say=hello + /fooo/bar + /fooo/barr/baz + )) { + is($server->is_valid_entry_point($uri), 'TopLevel', '... got TopLevel where we expected'); +} + + Index: lib/CGI/Application/Server.pm =================================================================== --- lib/CGI/Application/Server.pm (.../trunk) (revision 14) +++ lib/CGI/Application/Server.pm (.../branches/fix-empty-target-take-2) (revision 14) @@ -67,6 +67,11 @@ $uri =~ s/\/[^\/]*$//; } + # Check to see if there's an entry for '/' + if (exists $self->{entry_points}{'/'}) { + return ($uri, $self->{entry_points}{'/'}); + } + # Didn't find anything. Oh, well. return; } @@ -166,6 +171,7 @@ =head1 SYNOPSIS use CGI::Application::Server; + use MyCGIApp::DefaultApp; my $server = CGI::Application::Server->new(); @@ -173,6 +179,7 @@ $server->document_root('./htdocs'); $server->entry_points({ + '/' => 'MyCGIApp::DefaultApp', '/index.cgi' => 'MyCGIApp', '/admin' => 'MyCGIApp::Admin', '/account' => 'MyCGIApp::Account::Dispatch',