瀏覽代碼

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}`;
 };