Skip to content

Commit 7eb5fec

Browse files
committed
feat: output decoded url
1 parent 8b08cd0 commit 7eb5fec

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cesarlai/picgo-plugin-filename-format",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"author": "Cesar Lai",
55
"description": "A picgo plugin to format filename by your setting.",
66
"main": "dist/index.js",

src/afterUploadPlugins.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import type { IPicGo } from 'picgo'
2+
3+
/**
4+
* afterUploadPlugins handle function
5+
*/
6+
const handleAfterUploadPlugins = (ctx: IPicGo) => {
7+
ctx.output = ctx.output.map((item) => ({
8+
...item,
9+
imgUrl: item.imgUrl ? decodeURIComponent(item.imgUrl) : item.imgUrl
10+
}))
11+
12+
return ctx
13+
}
14+
15+
export default handleAfterUploadPlugins

src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { IPicGo } from 'picgo'
22
import handleBeforeTransformPlugins from './beforeTransformPlugins'
33
import handleBeforeUploadPlugins from './beforeUploadPlugins'
4+
import handleAfterUploadPlugins from './afterUploadPlugins'
45

56
const PLUGIN_NAME: Readonly<string> = 'filename-format'
67

@@ -15,6 +16,9 @@ function pluginImageNameFormat(ctx: IPicGo) {
1516
ctx.helper.beforeUploadPlugins.register(PLUGIN_NAME, {
1617
handle: handleBeforeUploadPlugins
1718
})
19+
ctx.helper.afterUploadPlugins.register(PLUGIN_NAME, {
20+
handle: handleAfterUploadPlugins
21+
})
1822
}
1923

2024
return {

0 commit comments

Comments
 (0)