4 use Test::More tests => 17;
6 BEGIN { use_ok("IkiWiki::Plugin::apache404"); }
8 sub cgi_page_from_404 {
9 return IkiWiki::Plugin::apache404::cgi_page_from_404(shift, shift,
13 $IkiWiki::config{htmlext} = 'html';
15 is(cgi_page_from_404('/', 'http://example.com', 1), 'index');
16 is(cgi_page_from_404('/index.html', 'http://example.com', 0), 'index');
17 is(cgi_page_from_404('/', 'http://example.com/', 1), 'index');
18 is(cgi_page_from_404('/index.html', 'http://example.com/', 0), 'index');
20 is(cgi_page_from_404('/~user/foo/bar', 'http://example.com/~user', 1),
22 is(cgi_page_from_404('/~user/foo/bar/index.html', 'http://example.com/~user', 1),
24 is(cgi_page_from_404('/~user/foo/bar/', 'http://example.com/~user', 1),
26 is(cgi_page_from_404('/~user/foo/bar.html', 'http://example.com/~user', 0),
29 is(cgi_page_from_404('/~user/foo/bar', 'http://example.com/~user/', 1),
31 is(cgi_page_from_404('/~user/foo/bar/index.html', 'http://example.com/~user/', 1),
33 is(cgi_page_from_404('/~user/foo/bar/', 'http://example.com/~user/', 1),
35 is(cgi_page_from_404('/~user/foo/bar.html', 'http://example.com/~user/', 0),
38 is(cgi_page_from_404('/~user/foo', 'https://example.com/~user', 1),
40 is(cgi_page_from_404('/~user/foo/index.html', 'https://example.com/~user', 1),
42 is(cgi_page_from_404('/~user/foo/', 'https://example.com/~user', 1),
44 is(cgi_page_from_404('/~user/foo.html', 'https://example.com/~user', 0),