From b45d94017d79bceb0ecd16b08dd180294921ae42 Mon Sep 17 00:00:00 2001 From: qwqcode <22412567+qwqcode@users.noreply.github.com> Date: Sun, 17 Dec 2023 01:29:59 +0800 Subject: [PATCH] fix(api/img-upload): `public_path` config enables the use of full url (#659) (#664) --- server/handler/img_upload.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/server/handler/img_upload.go b/server/handler/img_upload.go index 8cc33d1b4..83987a656 100644 --- a/server/handler/img_upload.go +++ b/server/handler/img_upload.go @@ -167,7 +167,15 @@ func ImgUpload(app *core.App, router fiber.Router) { if baseURL == "" { baseURL = config.IMG_UPLOAD_PUBLIC_PATH } - imgURL := path.Join(baseURL, filename) + + var imgURL string + if utils.ValidateURL(baseURL) { + // full url + imgURL = strings.TrimSuffix(baseURL, "/") + "/" + filename + } else { + // relative path + imgURL = path.Join(baseURL, filename) + } // 使用 upgit if app.Conf().ImgUpload.Upgit.Enabled {