chore: allow // comments in config.json

This commit is contained in:
Andreas Hubel 2022-12-25 02:12:53 +01:00
parent affc820965
commit 6fc8b204b2
2 changed files with 13 additions and 1 deletions

View file

@ -173,6 +173,17 @@ function slugify($text)
return $text;
}
/**
* From https://stackoverflow.com/a/10252511/319266
* @param string $str
* @return string
*/
function strip_comments($str) {
return preg_replace('![ \t]+//.*[ \t]*[\r\n]!', '', $str);
}
function do_download($url, $cache, $return_response = false)
{
$handle = curl_init($url);

View file

@ -107,7 +107,8 @@ class Conferences
if (file_exists($configfile)) {
$data = file_get_contents($configfile);
$config = json_decode($data);
$config = json_decode(strip_comments($data));
if(is_null($config)) {
throw new ConfigException("Loading $configfile did not return an object. Maybe it's not a real JSON file?" . json_last_error_msg());