Skip to content

Commit

Permalink
fix: cannot read properties of undefined (reading 'content') (#419)
Browse files Browse the repository at this point in the history
  • Loading branch information
bravekingzhang committed Sep 18, 2024
1 parent e8b2c18 commit 30f0792
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions src/utils/file.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import { giteeConfig, githubConfig } from '@/config'
import fetch from '@/utils/fetch'
import { base64encode, safe64, utf16to8 } from '@/utils/tokenTools'
import * as tokenTools from '@/utils/tokenTools'
import Buffer from 'buffer-from'
import COS from 'cos-js-sdk-v5'
import CryptoJS from 'crypto-js'
Expand All @@ -10,6 +6,10 @@ import * as Minio from 'minio'
import * as qiniu from 'qiniu-js'
import OSS from 'tiny-oss'
import { v4 as uuidv4 } from 'uuid'
import * as tokenTools from '@/utils/tokenTools'
import { base64encode, safe64, utf16to8 } from '@/utils/tokenTools'
import fetch from '@/utils/fetch'
import { giteeConfig, githubConfig } from '@/config'

function getConfig(useDefault: boolean, platform: string) {
if (useDefault) {
Expand Down Expand Up @@ -87,7 +87,7 @@ async function ghFileUpload(content: string, filename: string) {
content: {
download_url: string
}
data: {
data?: {
content: {
download_url: string
}
Expand All @@ -106,7 +106,7 @@ async function ghFileUpload(content: string, filename: string) {
})
const githubResourceUrl = `raw.githubusercontent.com/${username}/${repo}/${branch}/`
const cdnResourceUrl = `fastly.jsdelivr.net/gh/${username}/${repo}@${branch}/`
res.content = res.data.content || res.content
res.content = res.data?.content || res.content
return useDefault
? res.content.download_url.replace(githubResourceUrl, cdnResourceUrl)
: res.content.download_url
Expand Down

0 comments on commit 30f0792

Please sign in to comment.