[^/]+)/(?P[^/]+)/(?P[^/]+)/(?P.+)/.+$~"; preg_match( $p, $pattern, $m ); $apiURL = "https://api.github.com/repos/{$m['org']}/{$m['repo']}/contents/{$m['path']}"; $json = \Http::get( $apiURL ); if ( !$json ) { throw new \Exception( "Unable to get directory listing for {$m['org']}/{$m['repo']}" ); } $files = []; $json = \FormatJson::decode( $json, true ); foreach ( $json as $fileinfo ) { $fileurl = dirname( $pattern ) . '/' . $fileinfo['name']; $file = $this->fetchFile( $fileurl ); if ( $file ) { $files[$fileurl] = $file; } } return $files; } }