Pārlūkot izejas kodu

Add support for all URL schemas. Resolves #195

poeti8 6 gadi atpakaļ
vecāks
revīzija
b94eaefd0d
1 mainītis faili ar 2 papildinājumiem un 1 dzēšanām
  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));