26 $domain = preg_quote(
'https://raw.github.com/',
'~' );
27 $p =
"~^$domain(?P<org>[^/]+)/(?P<repo>[^/]+)/(?P<branch>[^/]+)/(?P<path>.+)/.+$~";
28 preg_match( $p, $pattern, $m );
30 $apiURL =
"https://api.github.com/repos/{$m['org']}/{$m['repo']}/contents/{$m['path']}";
31 $json = \Http::get( $apiURL );
33 throw new \Exception(
"Unable to get directory listing for {$m['org']}/{$m['repo']}" );
37 $json = \FormatJson::decode( $json,
true );
39 $fileurl = dirname( $pattern ) .
'/' .
$fileinfo[
'name'];
40 $file = $this->fetchFile( $fileurl );
42 $files[$fileurl] = $file;