Browse Source

fix[ExternalLink]: fixed bug when url include chinese

Pan 6 năm trước cách đây
mục cha
commit
54c2b2848e

+ 4 - 0
src/utils/index.js

@@ -68,3 +68,7 @@ export function formatTime(time, option) {
     )
   }
 }
+
+export function isExternal(path) {
+  return /^(https?:|mailto:|tel:)/.test(path)
+}

+ 2 - 2
src/views/layout/components/Sidebar/Link.vue

@@ -7,7 +7,7 @@
 </template>
 
 <script>
-import { validateURL } from '@/utils/validate'
+import { isExternal } from '@/utils'
 
 export default {
   props: {
@@ -18,7 +18,7 @@ export default {
   },
   methods: {
     isExternalLink(routePath) {
-      return validateURL(routePath)
+      return isExternal(routePath)
     },
     linkProps(url) {
       if (this.isExternalLink(url)) {

+ 2 - 2
src/views/layout/components/Sidebar/SidebarItem.vue

@@ -35,7 +35,7 @@
 
 <script>
 import path from 'path'
-import { validateURL } from '@/utils/validate'
+import { isExternal } from '@/utils'
 import Item from './Item'
 import AppLink from './Link'
 
@@ -94,7 +94,7 @@ export default {
       return path.resolve(this.basePath, routePath)
     },
     isExternalLink(routePath) {
-      return validateURL(routePath)
+      return isExternal(routePath)
     }
   }
 }