瀏覽代碼

Add support for all URL schemas. Resolves #195

poeti8 6 年之前
父節點
當前提交
b94eaefd0d
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      server/controllers/validateBodyController.js

+ 2 - 1
server/controllers/validateBodyController.js

@@ -74,7 +74,8 @@ exports.validateUrl = async ({ body, user }, res, next) => {
 
   // Validate URL
   const isValidUrl = urlRegex({ exact: true, strict: false }).test(body.target);
-  if (!isValidUrl) return res.status(400).json({ error: 'URL is not valid.' });
+  if (!isValidUrl && !/^\w+:\/\//.test(body.target))
+    return res.status(400).json({ error: 'URL is not valid.' });
 
   // If target is the URL shortener itself
   const { host } = URL.parse(addProtocol(body.target));