From 784c332650223b60ecbf85ecb78b1e2850255cca Mon Sep 17 00:00:00 2001 From: Duncan Bayne Date: Fri, 25 Aug 2023 16:48:04 +1000 Subject: [PATCH] Don't concatenate Web path since we don't support relative paths --- lib/Halp/AtomFeed.pm | 4 ++-- t/Halp/atom_feed_test.t | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Halp/AtomFeed.pm b/lib/Halp/AtomFeed.pm index d3934af..1a8091e 100644 --- a/lib/Halp/AtomFeed.pm +++ b/lib/Halp/AtomFeed.pm @@ -29,8 +29,8 @@ sub feed_for { my $full_path = $file->{filename}; if (-f $full_path) { my $contents = read_file($full_path); - $feed_directory = File::Spec->catfile($web_path, dirname($full_path)); - my $relative_path = rel2abs($full_path, $web_path); + $feed_directory = dirname($full_path); + my $relative_path = rel2abs($feed_directory, $web_path); $updated_at = `cd $feed_directory; git log --reverse --pretty='format:%ad' --date=iso8601-strict -- $relative_path | head -1`; chomp($updated_at); diff --git a/t/Halp/atom_feed_test.t b/t/Halp/atom_feed_test.t index 9a09483..41b6e4f 100644 --- a/t/Halp/atom_feed_test.t +++ b/t/Halp/atom_feed_test.t @@ -11,7 +11,11 @@ use Test::More; use Test::More tests => 8; -my $feed = feed_for('/atom_feed/feed.xml', './t/fixtures/atom_feed/feed.xml', rel2abs('.'), 'example.com', {email => 'author@example.com', name => 'An Author'}); +my $feed = feed_for('/feed.xml', + rel2abs('./t/fixtures/atom_feed/feed.xml'), + 'example.com', + {email => 'author@example.com', name => 'An Author'}); + my $xml = Mojo::DOM->new->xml(1)->parse($feed); is($xml->at('feed')->at('title')->text, 'Test Title', 'The Atom feed has the correct title.'); -- 2.45.2