Skip to content

Commit

Permalink
fix: resolve PR page link via response
Browse files Browse the repository at this point in the history
  • Loading branch information
EnixCoda committed Jun 3, 2022
1 parent 5e2c580 commit 32fa56e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/platforms/GitHub/API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,23 +134,23 @@ export async function getPullPageDocuments(
if (!baseSHA || !headSHA) throw new Error(`Cannot fetch SHA for comparison`)

// The SHA used to be retrieved from DOM of the pull page, but they can be unreliable if the PR has conflicts
const search = new URLSearchParams(window.location.search)
let search = new URLSearchParams(window.location.search)
search.set('lines', '0')
search.set('sha1', baseSHA)
search.set('sha2', headSHA)
let lines = 0
const diffsDOMs: Document[] = []
while (true) {
search.set('lines', lines.toString())
const diffsDOM = await getDOM(
`https://${window.location.host}/${userName}/${repoName}/diffs?${search}`,
)
diffsDOMs.push(diffsDOM)

if (diffsDOM.querySelector('.js-diff-progressive-container')) {
lines += 3000
} else {
break
}
const src = diffsDOM
.querySelector('.js-diff-progressive-container include-fragment')
?.getAttribute('src')
if (!src) break

search = new URL(src, window.location.origin).searchParams
}
return diffsDOMs
}
Expand Down

0 comments on commit 32fa56e

Please sign in to comment.