fix[ExternalLink]: fixed bug when url include chinese #1182

This commit is contained in:
Pan 2018-10-10 17:43:33 +08:00
parent 90d3e314c0
commit 323408f8d9
3 changed files with 8 additions and 4 deletions

View file

@ -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)
}

View file

@ -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)) {

View file

@ -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'
@ -98,7 +98,7 @@ export default {
return path.resolve(this.basePath, routePath)
},
isExternalLink(routePath) {
return validateURL(routePath)
return isExternal(routePath)
},
generateTitle
}