fix: preserve search params for pr link

This commit is contained in:
EnixCoda 2020-06-26 21:16:55 +08:00
parent 184a91875a
commit e4a9277d12
No known key found for this signature in database
GPG key ID: 0C1A07377913A1DD
2 changed files with 4 additions and 2 deletions

View file

@ -95,7 +95,9 @@ export async function getPullPageDocument(
repoName: string,
pullId: string,
): Promise<Document> {
const url = `https://${window.location.host}/${userName}/${repoName}/pull/${pullId}/files?_pjax=%23js-repo-pjax-container`
const search = new URLSearchParams(window.location.search)
search.set('_pjax', '#js-repo-pjax-container')
const url = `https://${window.location.host}/${userName}/${repoName}/pull/${pullId}/files?${search}`
return new DOMParser().parseFromString(await (await fetch(url)).text(), 'text/html')
}

View file

@ -110,7 +110,7 @@ export const GitHub: Platform = {
type: 'blob',
name: item.filename?.replace(/^.*\//, '') || '',
url: id
? `https://${window.location.host}/${metaData.userName}/${metaData.repoName}/pull/${pullId}/files#${id}`
? `https://${window.location.host}/${metaData.userName}/${metaData.repoName}/pull/${pullId}/files${window.location.search}#${id}`
: `#`,
contents: undefined,
sha: item.sha,