Explorar o código

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

poeti8 %!s(int64=6) %!d(string=hai) anos
pai
achega
cd49395c02
Modificáronse 1 ficheiros con 1 adicións e 2 borrados
  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}`;
 };