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