Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[新功能需求] Upload支持回显无后缀的图片 #870

Open
nicopcat opened this issue Jan 23, 2025 · 0 comments
Open

[新功能需求] Upload支持回显无后缀的图片 #870

nicopcat opened this issue Jan 23, 2025 · 0 comments
Labels
feature: need confirm 待确认的新特性

Comments

@nicopcat
Copy link

这个功能解决了什么问题?

目前无法回显无后缀的图片,没有解决办法。查看源码,发现是这个方法,匹配得有点死了。

/**
 * 检查提供的URL是否为图片URL。
 * @param url 待检查的URL字符串。
 * @returns 返回一个布尔值,如果URL是图片格式,则为true;否则为false。
 */
export function isImageUrl(url: string): boolean {
  // 使用正则表达式匹配图片URL
  const imageRegex = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg|image)/i
  return imageRegex.test(url)
}

你期望的 API 是什么样子的?

或许可以增加一个字段比如 isImage,指定该文件为图片,就不走这个校验直接回显。

@nicopcat nicopcat added the feature: need confirm 待确认的新特性 label Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: need confirm 待确认的新特性
Projects
None yet
Development

No branches or pull requests

1 participant