Ganto 2 years ago
parent
commit
2cc7629890
1 changed files with 13 additions and 0 deletions
  1. 13 0
      src/pages/Home.vue

+ 13 - 0
src/pages/Home.vue

@@ -52,11 +52,24 @@ const data = reactive({
 const subPathSwitch = ref(false)
 const subPath = ref('')
 const btn = () => {
+    let count = 0;
     if (metaData.value.trim().length <= 0) return ElMessage({ message: '至少输入一个域名', type: 'warning', });
     data.urlArr = metaData.value.trim().split(/\r?\n/)
     data.urlArr = data.urlArr.filter(item => {
         return item.trim().length > 0
     })
+    data.urlArr.forEach(item => {
+        const regex = /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([a-z]{2,6})$/
+        item = item.indexOf("https://") !== -1 ? item.replace(new RegExp("https://"), "") : item;
+        item = item.indexOf("http://") !== -1 ? item.replace(new RegExp("http://"), "") : item;
+        item = item[item.length - 1] === '/' ? item.slice(0, item.length-1) : item;
+        const flag = regex.test(item.trim())
+        if(!flag) {
+            count++;
+        }
+    })
+    count > 0 ? ElMessage({ message: '请检查域名有误!!!', type: 'error', }) : null
+    console.warn("请检查域名有误!!!")
     data.urlArr = data.urlArr.map(item => {
         if (item.indexOf("http://") === -1) {
             if (item.indexOf("https://") === -1) {