aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Geocode.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2017-10-04 18:17:13 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2017-10-10 23:16:14 +0100
commit5934b383754a2d298100a674a1ccefc2cb9e50af (patch)
tree81f0e217836eddea478bea268371ec02b5887942 /perllib/FixMyStreet/Geocode.pm
parent6f0ee01f37029c0fdabd161646b8dbbdec676165 (diff)
Simplify geocode cache read/writing.
Don't think the return data ever needs decoding.
Diffstat (limited to 'perllib/FixMyStreet/Geocode.pm')
-rw-r--r--perllib/FixMyStreet/Geocode.pm9
1 files changed, 5 insertions, 4 deletions
diff --git a/perllib/FixMyStreet/Geocode.pm b/perllib/FixMyStreet/Geocode.pm
index b5bb7249c..dd1adfe71 100644
--- a/perllib/FixMyStreet/Geocode.pm
+++ b/perllib/FixMyStreet/Geocode.pm
@@ -73,18 +73,19 @@ sub cache {
my $cache_file = $cache_dir->child(md5_hex($url));
my $js;
if (-s $cache_file && -M $cache_file <= 7 && !FixMyStreet->config('STAGING_SITE')) {
- $js = $cache_file->slurp;
+ # uncoverable statement
+ $js = $cache_file->slurp_utf8;
} else {
$url .= '&' . $args if $args;
$ua->timeout(15);
$js = LWP::Simple::get($url);
- $js = encode_utf8($js) if utf8::is_utf8($js);
$cache_dir->mkpath;
if ($js && (!$re || $js !~ $re) && !FixMyStreet->config('STAGING_SITE')) {
- $cache_file->spew($js);
+ # uncoverable statement
+ $cache_file->spew_utf8($js);
}
}
- $js = JSON->new->utf8->allow_nonref->decode($js) if $js;
+ $js = JSON->new->allow_nonref->decode($js) if $js;
return $js;
}