From e4a9277d1205241627390f36680a81edeffa6f7d Mon Sep 17 00:00:00 2001 From: EnixCoda Date: Fri, 26 Jun 2020 21:16:55 +0800 Subject: [PATCH] fix: preserve search params for pr link --- src/platforms/GitHub/API.ts | 4 +++- src/platforms/GitHub/index.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/platforms/GitHub/API.ts b/src/platforms/GitHub/API.ts index e411651..6b7cbf7 100644 --- a/src/platforms/GitHub/API.ts +++ b/src/platforms/GitHub/API.ts @@ -95,7 +95,9 @@ export async function getPullPageDocument( repoName: string, pullId: string, ): Promise { - 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') } diff --git a/src/platforms/GitHub/index.ts b/src/platforms/GitHub/index.ts index b497a90..2d254ef 100644 --- a/src/platforms/GitHub/index.ts +++ b/src/platforms/GitHub/index.ts @@ -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,