Skip to content

Commit

Permalink
fix[ExternalLink]: fixed bug when url include chinese PanJiaChen#1182
Browse files Browse the repository at this point in the history
  • Loading branch information
PanJiaChen committed Oct 10, 2018
1 parent 90d3e31 commit 323408f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,7 @@ export function deepClone(source) {
export function uniqueArr(arr) {
return Array.from(new Set(arr))
}

export function isExternal(path) {
return /^(https?:|mailto:|tel:)/.test(path)
}
4 changes: 2 additions & 2 deletions src/views/layout/components/Sidebar/Link.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</template>

<script>
import { validateURL } from '@/utils/validate'
import { isExternal } from '@/utils'
export default {
props: {
Expand All @@ -18,7 +18,7 @@ export default {
},
methods: {
isExternalLink(routePath) {
return validateURL(routePath)
return isExternal(routePath)
},
linkProps(url) {
if (this.isExternalLink(url)) {
Expand Down
4 changes: 2 additions & 2 deletions src/views/layout/components/Sidebar/SidebarItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<script>
import path from 'path'
import { generateTitle } from '@/utils/i18n'
import { validateURL } from '@/utils/validate'
import { isExternal } from '@/utils'
import Item from './Item'
import AppLink from './Link'
import FixiOSBug from './FixiOSBug'
Expand Down Expand Up @@ -98,7 +98,7 @@ export default {
return path.resolve(this.basePath, routePath)
},
isExternalLink(routePath) {
return validateURL(routePath)
return isExternal(routePath)
},
generateTitle
}
Expand Down

0 comments on commit 323408f

Please sign in to comment.