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