File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -57,17 +57,16 @@ function getPrefix(url: DirectoryUrl): string {
5757 return `${ baseUrl } /${ url . repo } /tree/${ url . branch } ${ url . path } ` . replace ( / \/ $ / , '' )
5858}
5959async function fetchFilesList ( url : DirectoryUrl , options ?: { requestInit ?: RequestInit , accessToken ?: string } ) : Promise < FileMetadata [ ] > {
60- const apiURL = `https://api.github.com/repos/${ url . repo } /contents/${ url . path } ?ref=${ url . branch } `
61- const headers : Record < string , string > = {
62- 'Accept' : 'application/vnd.github+json' ,
63- }
60+ const apiURL = `https://api.github.com/repos/${ url . repo } /contents${ url . path } ?ref=${ url . branch } `
61+ const headers = new Headers ( options ?. requestInit ?. headers )
62+ headers . set ( 'Accept' , 'application/vnd.github+json' )
6463 if ( options ?. accessToken ) {
65- headers . Authorization = `Bearer ${ options . accessToken } `
64+ headers . set ( ' Authorization' , `Bearer ${ options . accessToken } ` )
6665 }
6766 const response = await fetch ( apiURL , {
67+ ...options ?. requestInit ,
6868 method : 'GET' ,
6969 headers,
70- ...options ?. requestInit ,
7170 } )
7271 if ( ! response . ok ) {
7372 throw new Error ( `GitHub API error: ${ response . status } ${ response . statusText } - ${ await response . text ( ) } ` )
You can’t perform that action at this time.
0 commit comments