diff --git a/package.json b/package.json index 188c81c..b83457a 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "keycode": "^2.2.0", "lodash-id": "^0.14.0", "lowdb": "^1.0.0", - "picgo": "^1.5.0-alpha.10", + "picgo": "^1.5.0-alpha.15", "qrcode.vue": "^1.7.0", "shell-path": "2.1.0", "uuidv4": "^6.2.11", diff --git a/src/main/utils/pasteTemplate.ts b/src/main/utils/pasteTemplate.ts index 06000a2..b2b2e91 100644 --- a/src/main/utils/pasteTemplate.ts +++ b/src/main/utils/pasteTemplate.ts @@ -1,4 +1,5 @@ import { IPasteStyle } from '#/types/enum' +import { handleUrlEncode } from '#/utils/common' const formatCustomLink = (customLink: string, item: ImgInfo) => { const fileName = item.fileName!.replace(new RegExp(`\\${item.extname}$`), '') @@ -18,7 +19,7 @@ const formatCustomLink = (customLink: string, item: ImgInfo) => { } export default (style: IPasteStyle, item: ImgInfo, customLink: string | undefined) => { - const url = item.url || item.imgUrl + const url = handleUrlEncode(item.url || item.imgUrl) const _customLink = customLink || '$url' const tpl = { markdown: `![](${url})`, diff --git a/src/universal/utils/common.ts b/src/universal/utils/common.ts index 78d59fd..357b0a3 100644 --- a/src/universal/utils/common.ts +++ b/src/universal/utils/common.ts @@ -2,7 +2,7 @@ export const isUrl = (url: string): boolean => (url.startsWith('http://') || url export const isUrlEncode = (url: string): boolean => { url = url || '' try { - return url !== decodeURIComponent(url) + return url !== decodeURI(url) } catch (e) { // if some error caught, try to let it go return true @@ -11,7 +11,7 @@ export const isUrlEncode = (url: string): boolean => { export const handleUrlEncode = (url: string): string => { if (!isUrlEncode(url)) { - url = encodeURIComponent(url) + url = encodeURI(url) } return url } diff --git a/yarn.lock b/yarn.lock index 83e34d7..f97da7b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9919,10 +9919,10 @@ performance-now@^2.1.0: resolved "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns= -picgo@^1.5.0-alpha.10: - version "1.5.0-alpha.10" - resolved "https://registry.npmjs.org/picgo/-/picgo-1.5.0-alpha.10.tgz#fd567ac60c831395d5f16b80cf59646cab492c9a" - integrity sha512-uFVFXxocbqXyc3lpGGIY2Sn55osXZWrTsNh9/CBSgJSqRVkp13nYnLMffZTp2+zzd/mDTpdqf/AUuEFI9dho+A== +picgo@^1.5.0-alpha.15: + version "1.5.0-alpha.15" + resolved "https://registry.npmjs.org/picgo/-/picgo-1.5.0-alpha.15.tgz#406c1cd48afc5c98f1d5084596e8bcecb637ad58" + integrity sha512-+uU2gbFi/kc5qi0wrqk0hSFusUqEYKTay9hIHcQ13un+7xx5kwir99mwwKpNB+K8wHARntjurN9HCZEszgTKmQ== dependencies: "@picgo/i18n" "^1.0.0" "@picgo/store" "^2.0.2"