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