summaryrefslogtreecommitdiff
path: root/t/rssurls.t
blob: 87077049609091c522f0dc577750c108ccde9369 (plain)
  1. #!/usr/bin/perl
  2. use warnings;
  3. use strict;
  4. use Test::More tests => 13;
  5. BEGIN { use_ok("IkiWiki::Plugin::inline"); }
  6. # Test the absolute_urls function, used to fix up relative urls for rss
  7. # feeds.
  8. sub test {
  9. my $input=shift;
  10. my $baseurl=shift;
  11. my $expected=shift;
  12. $expected=~s/URL/$baseurl/g;
  13. is(IkiWiki::absolute_urls($input, $baseurl), $expected);
  14. # try it with single quoting -- it's ok if the result comes back
  15. # double or single-quoted
  16. $input=~s/"/'/g;
  17. my $expected_alt=$expected;
  18. $expected_alt=~s/"/'/g;
  19. my $ret=IkiWiki::absolute_urls($input, $baseurl);
  20. ok(($ret eq $expected) || ($ret eq $expected_alt), "$ret vs $expected");
  21. }
  22. sub unchanged {
  23. test($_[0], $_[1], $_[0]);
  24. }
  25. my $url="http://example.com/blog/foo/";
  26. unchanged("foo", $url);
  27. unchanged('<a href="http://other.com/bar.html">', $url, );
  28. test('<a href="bar.html">', $url, '<a href="URLbar.html">');
  29. test('<a href="/bar.html">', $url, '<a href="http://example.com/bar.html">');
  30. test('<img src="bar.png" />', $url, '<img src="URLbar.png" />');
  31. test('<img src="/bar.png" />', $url, '<img src="http://example.com/bar.png" />');
  32. # off until bug #603736 is fixed
  33. #test('<video controls src="bar.ogg">', $url, '<video controls src="URLbar.ogg">');