Skip to content

Commit

Permalink
fix: github path error
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Apr 23, 2024
1 parent 0fcd437 commit e3e2b87
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions libs/Universal-PicGo-Core/src/plugins/uploader/github.ts
Expand Up @@ -13,6 +13,7 @@ import mime from "mime-types"
import { ILocalesKey } from "../../i18n/zh-CN"
import { bufferToBase64 } from "../../utils/common"
import { IBuildInEvent } from "../../utils/enums"
import { browserPathJoin } from "../../utils/browserUtils"

const postOptions = (fileName: string, options: IGithubConfig, data: any): AxiosRequestConfig => {
const path = options.path || ""
Expand Down Expand Up @@ -66,9 +67,12 @@ const handle = async (ctx: IPicGo): Promise<IPicGo> => {
delete img.base64Image
delete img.buffer
if (githubOptions.customUrl) {
img.imgUrl = `${githubOptions.customUrl}/${encodeURI(githubOptions.path)}${encodeURIComponent(
img.fileName
)}`
let imgUrl = githubOptions.customUrl
if (githubOptions.path) {
imgUrl = browserPathJoin(imgUrl, encodeURI(githubOptions.path))
}
imgUrl = browserPathJoin(imgUrl, encodeURIComponent(img.fileName))
img.imgUrl = imgUrl
} else {
img.imgUrl = body.content.download_url
}
Expand Down

0 comments on commit e3e2b87

Please sign in to comment.