Skip to content

Commit 3802f6f

Browse files
committed
fix[ExternalLink]: fixed bug when url include chinese #1182
1 parent 90d3e31 commit 3802f6f

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/utils/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -296,3 +296,7 @@ export function deepClone(source) {
296296
export function uniqueArr(arr) {
297297
return Array.from(new Set(arr))
298298
}
299+
300+
export function isExternal(path) {
301+
return /^(https?:|mailto:|tel:)/.test(path)
302+
}

src/views/layout/components/Sidebar/Link.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</template>
88

99
<script>
10-
import { validateURL } from '@/utils/validate'
10+
import { isExternal } from '@/utils'
1111
1212
export default {
1313
props: {
@@ -18,7 +18,7 @@ export default {
1818
},
1919
methods: {
2020
isExternalLink(routePath) {
21-
return validateURL(routePath)
21+
return isExternal(routePath)
2222
},
2323
linkProps(url) {
2424
if (this.isExternalLink(url)) {

src/views/layout/components/Sidebar/SidebarItem.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<script>
3838
import path from 'path'
3939
import { generateTitle } from '@/utils/i18n'
40-
import { validateURL } from '@/utils/validate'
40+
import { isExternal } from '@/utils'
4141
import Item from './Item'
4242
import AppLink from './Link'
4343
import FixiOSBug from './FixiOSBug'
@@ -98,7 +98,7 @@ export default {
9898
return path.resolve(this.basePath, routePath)
9999
},
100100
isExternalLink(routePath) {
101-
return validateURL(routePath)
101+
return isExternal(routePath)
102102
},
103103
generateTitle
104104
}

0 commit comments

Comments
 (0)