fix id collisions causing truncated shield svgs

This commit is contained in:
mappu 2017-07-08 11:50:21 +12:00
parent 8adadb0be1
commit 5801030e31

View File

@ -15,6 +15,12 @@ function mkshield($left_str, $right_str, $color_str) {
} else {
$retn = file_get_contents('https://img.shields.io/badge/'.$filename);
// We need unique IDs
$prefix = substr(sha1($filename), 8).'-';
$retn = str_replace('id="', 'id="'.$prefix, $retn);
$retn = str_replace('url(#', 'url(#'.$prefix, $retn);
file_put_contents($cache_path, $retn);
return $retn;