fix: 限制粘贴图片地址来源

This commit is contained in:
zxc 2024-08-18 10:00:39 +08:00
parent 4d9471e582
commit b7ad7644cc
2 changed files with 11 additions and 8 deletions

View File

@ -3,7 +3,7 @@ import { useKeyboardStore } from '@/store'
import { pasteCustomClipboardString } from '@/utils/clipboard'
import { parseText2Paragraphs } from '@/utils/textParser'
import { getImageDataURL, isSVGString, svg2File } from '@/utils/image'
import { isValidImgURL, isValidURL } from '@/utils/common'
import { isValidURL } from '@/utils/common'
import useCreateElement from '@/hooks/useCreateElement'
import useAddSlidesOrElements from '@/hooks/useAddSlidesOrElements'
@ -12,6 +12,16 @@ interface PasteTextClipboardDataOptions {
onlyElements?: boolean
}
/**
* URL字符串
*
*
* 访
*/
const isValidImgURL = (url: string) => {
return /^https:\/\/pptist.cn(\/[\w-./?%&=]*)?\.(jpg|jpeg|png|svg|webp)(\?.*)?$/i.test(url)
}
export default () => {
const { shiftKeyState } = storeToRefs(useKeyboardStore())

View File

@ -22,10 +22,3 @@ export const isPC = () => {
export const isValidURL = (url: string) => {
return /^(https?:\/\/)([\w-]+\.)+[\w-]{2,}(\/[\w-./?%&=]*)?$/i.test(url)
}
/**
* URL字符串
*/
export const isValidImgURL = (url: string) => {
return /^(https?:\/\/)([\w-]+\.)+[\w-]{2,}(\/[\w-./?%&=]*)?\.(jpg|jpeg|png|svg|webp)(\?.*)?$/i.test(url)
}