summaryrefslogtreecommitdiff
path: root/t/404.t
blob: 0bb3c60637e3935c9a743029b5346ab800b7b4eb (plain)
  1. #!/usr/bin/perl
  2. use warnings;
  3. use strict;
  4. use Test::More tests => 17;
  5. BEGIN { use_ok("IkiWiki::Plugin::404"); }
  6. sub cgi_page_from_404 {
  7. return IkiWiki::Plugin::404::cgi_page_from_404(shift, shift, shift);
  8. }
  9. $IkiWiki::config{htmlext} = 'html';
  10. is(cgi_page_from_404('/', 'http://example.com', 1), 'index');
  11. is(cgi_page_from_404('/index.html', 'http://example.com', 0), 'index');
  12. is(cgi_page_from_404('/', 'http://example.com/', 1), 'index');
  13. is(cgi_page_from_404('/index.html', 'http://example.com/', 0), 'index');
  14. is(cgi_page_from_404('/~user/foo/bar', 'http://example.com/~user', 1),
  15. 'foo/bar');
  16. is(cgi_page_from_404('/~user/foo/bar/index.html', 'http://example.com/~user', 1),
  17. 'foo/bar');
  18. is(cgi_page_from_404('/~user/foo/bar/', 'http://example.com/~user', 1),
  19. 'foo/bar');
  20. is(cgi_page_from_404('/~user/foo/bar.html', 'http://example.com/~user', 0),
  21. 'foo/bar');
  22. is(cgi_page_from_404('/~user/foo/bar', 'http://example.com/~user/', 1),
  23. 'foo/bar');
  24. is(cgi_page_from_404('/~user/foo/bar/index.html', 'http://example.com/~user/', 1),
  25. 'foo/bar');
  26. is(cgi_page_from_404('/~user/foo/bar/', 'http://example.com/~user/', 1),
  27. 'foo/bar');
  28. is(cgi_page_from_404('/~user/foo/bar.html', 'http://example.com/~user/', 0),
  29. 'foo/bar');
  30. is(cgi_page_from_404('/~user/foo', 'https://example.com/~user', 1),
  31. 'foo');
  32. is(cgi_page_from_404('/~user/foo/index.html', 'https://example.com/~user', 1),
  33. 'foo');
  34. is(cgi_page_from_404('/~user/foo/', 'https://example.com/~user', 1),
  35. 'foo');
  36. is(cgi_page_from_404('/~user/foo.html', 'https://example.com/~user', 0),
  37. 'foo');