From 070a3343f26c34f05ff4d9ed296d65e66622ac88 Mon Sep 17 00:00:00 2001 From: Pan Date: Tue, 19 Feb 2019 10:07:18 +0800 Subject: [PATCH] perf[utils]: optimize code --- src/utils/index.js | 4 ---- src/utils/validate.js | 4 ++++ src/views/layout/components/Sidebar/Link.vue | 2 +- src/views/layout/components/Sidebar/SidebarItem.vue | 8 +++----- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/utils/index.js b/src/utils/index.js index 821392e9..60a3922c 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -290,7 +290,3 @@ export function deepClone(source) { export function uniqueArr(arr) { return Array.from(new Set(arr)) } - -export function isExternal(path) { - return /^(https?:|mailto:|tel:)/.test(path) -} diff --git a/src/utils/validate.js b/src/utils/validate.js index ada0e7e2..dda046de 100644 --- a/src/utils/validate.js +++ b/src/utils/validate.js @@ -7,6 +7,10 @@ export function isvalidUsername(str) { return valid_map.indexOf(str.trim()) >= 0 } +export function isExternal(path) { + return /^(https?:|mailto:|tel:)/.test(path) +} + /* 合法uri*/ export function validateURL(textval) { const urlregex = /^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/ diff --git a/src/views/layout/components/Sidebar/Link.vue b/src/views/layout/components/Sidebar/Link.vue index cd2e0413..bff45cd8 100644 --- a/src/views/layout/components/Sidebar/Link.vue +++ b/src/views/layout/components/Sidebar/Link.vue @@ -7,7 +7,7 @@