Forráskód Böngészése

Use regex to detect URL schema (instead of URL module)

poeti8 6 éve
szülő
commit
cd49395c02
1 módosított fájl, 1 hozzáadás és 2 törlés
  1. 1 2
      server/utils/index.js

+ 1 - 2
server/utils/index.js

@@ -1,9 +1,8 @@
-const URL = require('url');
 const ms = require('ms');
 const { differenceInDays, differenceInHours, differenceInMonths } = require('date-fns');
 
 exports.addProtocol = url => {
-  const hasProtocol = /^https?/.test(URL.parse(url).protocol);
+  const hasProtocol = /^\w+:\/\//.test(url);
   return hasProtocol ? url : `http://${url}`;
 };