X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;ds=sidebyside;f=lib%2FY%2FAoC%2FUA.pm;h=725832406839ec5cc230add3ead9b4467d2184a9;hb=ec283da1f9eb5574ace9f827dc811be8a6c48e47;hp=ecee1b0721e8adca9d52ece1762e552fce35419d;hpb=78136e93bf5e13aabceb8834ab3748187ee74eee;p=aoc.git diff --git a/lib/Y/AoC/UA.pm b/lib/Y/AoC/UA.pm index ecee1b0..7258324 100644 --- a/lib/Y/AoC/UA.pm +++ b/lib/Y/AoC/UA.pm @@ -19,7 +19,7 @@ sub request($url, $args) { $cachefile = $cache_dir . '/' . $args->{cache_to}; $cache = Mojo::File->new("$cachefile"); - if ($args->{max_age}) { + if (defined $args->{max_age}) { $cache->remove if $cache->stat && time - $cache->stat->mtime @@ -29,7 +29,9 @@ sub request($url, $args) { if ($cache->stat) { say "\n", white('cached'), " response from $cachefile"; - return Mojo::DOM->new($cache->slurp); + return $args->{body} + ? $cache->slurp + : Mojo::DOM->new($cache->slurp); } }