mirror of
https://github.com/voc/streaming-website
synced 2024-11-10 06:34:17 +00:00
chore: allow // comments in config.json
This commit is contained in:
parent
affc820965
commit
6fc8b204b2
2 changed files with 13 additions and 1 deletions
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Reference in a new issue