Преглед на файлове

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

poeti8 преди 6 години
родител
ревизия
cd49395c02
променени са 1 файла, в които са добавени 1 реда и са изтрити 2 реда
  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}`;
 };