Skip to content

Commit c26014c

Browse files
committed
copilot comments
1 parent 380d885 commit c26014c

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

src/lib/sources/gitHubSource.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,16 @@ function getPrefix(url: DirectoryUrl): string {
5757
return `${baseUrl}/${url.repo}/tree/${url.branch}${url.path}`.replace(/\/$/, '')
5858
}
5959
async 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()}`)

0 commit comments

Comments
 (0)