Feature: add $extName for paste template

ISSUES CLOSED: #1000
This commit is contained in:
PiEgg
2022-10-31 17:13:51 +08:00
parent 33bfaa5959
commit 64e54d0b0b
7 changed files with 16 additions and 8 deletions

View File

@@ -4,11 +4,13 @@ import { handleUrlEncode } from '#/utils/common'
const formatCustomLink = (customLink: string, item: ImgInfo) => {
const fileName = item.fileName!.replace(new RegExp(`\\${item.extname}$`), '')
const url = item.url || item.imgUrl
const extName = item.extname
const formatObj = {
url,
fileName
fileName,
extName
}
const keys = Object.keys(formatObj) as ['url', 'fileName']
const keys = Object.keys(formatObj) as ['url', 'fileName', 'extName']
keys.forEach(item => {
if (customLink.indexOf(`$${item}`) !== -1) {
const reg = new RegExp(`\\$${item}`, 'g')