Skip to content

Commit

Permalink
🐛 Fix: encode url before finishing
Browse files Browse the repository at this point in the history
  • Loading branch information
Molunerfinn committed Apr 1, 2020
1 parent deec252 commit 7a6b39c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core/Lifecycle.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { EventEmitter } from 'events'
import PicGo from './PicGo'
import { Plugin } from '../utils/interfaces'
import { handleUrlEncode } from '../utils/common'

class Lifecycle extends EventEmitter {
configPath: string
Expand Down Expand Up @@ -85,7 +86,7 @@ class Lifecycle extends EventEmitter {
let msg = ''
let length = ctx.output.length
for (let i = 0; i < length; i++) {
msg += ctx.output[i].imgUrl
msg += handleUrlEncode(ctx.output[i].imgUrl)
if (i !== length - 1) {
msg += '\n'
}
Expand Down
10 changes: 10 additions & 0 deletions src/utils/common.ts
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
export const isUrl = (url: string): boolean => (url.startsWith('http://') || url.startsWith('https://'))
export const isUrlEncode = (url: string): boolean => {
url = url || ''
return url !== decodeURI(url)
}
export const handleUrlEncode = (url: string): string => {
if (!isUrlEncode(url)) {
url = encodeURI(url)
}
return url
}

0 comments on commit 7a6b39c

Please sign in to comment.