perf(PJAX): set proper url for blobs

Gitako used to request tree path for blobs, which causes 301
This commit is contained in:
EnixCoda 2018-06-29 00:22:59 +08:00
parent c625121735
commit 0ae743e10c
2 changed files with 3 additions and 3 deletions

View file

@ -24,8 +24,8 @@ async function getTreeData({ userName, repoName, branchName, accessToken }) {
return await request(url, { accessToken })
}
function getUrlForRedirect({ userName, repoName, branchName }, path) {
return `https://github.com/${userName}/${repoName}/tree/${branchName}/${path}`
function getUrlForRedirect({ userName, repoName, branchName }, type = 'blob', path) {
return `https://github.com/${userName}/${repoName}/${type}/${branchName}/${path}`
}
export default {

View file

@ -60,7 +60,7 @@ function parse(treeData, metaData) {
...item,
name: item.path.replace(/^.*\//, ''),
url: item.url
? GitHubHelper.getUrlForRedirect(metaData, item.path)
? GitHubHelper.getUrlForRedirect(metaData, item.type, item.path)
: null,
contents: item.type === 'tree' ? [] : null,
}