diff --git a/src/tool/util.js b/src/tool/util.js index b8f095c7..770fe315 100644 --- a/src/tool/util.js +++ b/src/tool/util.js @@ -672,6 +672,17 @@ function sketchToMask(sketchImage) { img.src = sketchImage; }); } + +function isValidUrl(string) { + try { + const url = new URL(string) + // 通常我们只需要 http 或 https 协议 + return url.protocol === "http:" || url.protocol === "https:" + } catch (err) { + return false + } +} + export { isEmail, getUploadUrl,