Skip to content

Commit 4de7a1d

Browse files
committed
🐛 Fix: url encode bug && copy-paste url encode bug
ISSUES CLOSED: #996
1 parent 404d766 commit 4de7a1d

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"keycode": "^2.2.0",
4949
"lodash-id": "^0.14.0",
5050
"lowdb": "^1.0.0",
51-
"picgo": "^1.5.0-alpha.10",
51+
"picgo": "^1.5.0-alpha.15",
5252
"qrcode.vue": "^1.7.0",
5353
"shell-path": "2.1.0",
5454
"uuidv4": "^6.2.11",

src/main/utils/pasteTemplate.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { IPasteStyle } from '#/types/enum'
2+
import { handleUrlEncode } from '#/utils/common'
23

34
const formatCustomLink = (customLink: string, item: ImgInfo) => {
45
const fileName = item.fileName!.replace(new RegExp(`\\${item.extname}$`), '')
@@ -18,7 +19,7 @@ const formatCustomLink = (customLink: string, item: ImgInfo) => {
1819
}
1920

2021
export default (style: IPasteStyle, item: ImgInfo, customLink: string | undefined) => {
21-
const url = item.url || item.imgUrl
22+
const url = handleUrlEncode(item.url || item.imgUrl)
2223
const _customLink = customLink || '$url'
2324
const tpl = {
2425
markdown: `![](${url})`,

src/universal/utils/common.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export const isUrl = (url: string): boolean => (url.startsWith('http://') || url
22
export const isUrlEncode = (url: string): boolean => {
33
url = url || ''
44
try {
5-
return url !== decodeURIComponent(url)
5+
return url !== decodeURI(url)
66
} catch (e) {
77
// if some error caught, try to let it go
88
return true
@@ -11,7 +11,7 @@ export const isUrlEncode = (url: string): boolean => {
1111

1212
export const handleUrlEncode = (url: string): string => {
1313
if (!isUrlEncode(url)) {
14-
url = encodeURIComponent(url)
14+
url = encodeURI(url)
1515
}
1616
return url
1717
}

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9919,10 +9919,10 @@ performance-now@^2.1.0:
99199919
resolved "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
99209920
integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=
99219921

9922-
picgo@^1.5.0-alpha.10:
9923-
version "1.5.0-alpha.10"
9924-
resolved "https://registry.npmjs.org/picgo/-/picgo-1.5.0-alpha.10.tgz#fd567ac60c831395d5f16b80cf59646cab492c9a"
9925-
integrity sha512-uFVFXxocbqXyc3lpGGIY2Sn55osXZWrTsNh9/CBSgJSqRVkp13nYnLMffZTp2+zzd/mDTpdqf/AUuEFI9dho+A==
9922+
picgo@^1.5.0-alpha.15:
9923+
version "1.5.0-alpha.15"
9924+
resolved "https://registry.npmjs.org/picgo/-/picgo-1.5.0-alpha.15.tgz#406c1cd48afc5c98f1d5084596e8bcecb637ad58"
9925+
integrity sha512-+uU2gbFi/kc5qi0wrqk0hSFusUqEYKTay9hIHcQ13un+7xx5kwir99mwwKpNB+K8wHARntjurN9HCZEszgTKmQ==
99269926
dependencies:
99279927
"@picgo/i18n" "^1.0.0"
99289928
"@picgo/store" "^2.0.2"

0 commit comments

Comments
 (0)