提交 323408f8 编写于 作者: P Pan

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

上级 90d3e314
...@@ -296,3 +296,7 @@ export function deepClone(source) { ...@@ -296,3 +296,7 @@ export function deepClone(source) {
export function uniqueArr(arr) { export function uniqueArr(arr) {
return Array.from(new Set(arr)) return Array.from(new Set(arr))
} }
export function isExternal(path) {
return /^(https?:|mailto:|tel:)/.test(path)
}
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
</template> </template>
<script> <script>
import { validateURL } from '@/utils/validate' import { isExternal } from '@/utils'
export default { export default {
props: { props: {
...@@ -18,7 +18,7 @@ export default { ...@@ -18,7 +18,7 @@ export default {
}, },
methods: { methods: {
isExternalLink(routePath) { isExternalLink(routePath) {
return validateURL(routePath) return isExternal(routePath)
}, },
linkProps(url) { linkProps(url) {
if (this.isExternalLink(url)) { if (this.isExternalLink(url)) {
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<script> <script>
import path from 'path' import path from 'path'
import { generateTitle } from '@/utils/i18n' import { generateTitle } from '@/utils/i18n'
import { validateURL } from '@/utils/validate' import { isExternal } from '@/utils'
import Item from './Item' import Item from './Item'
import AppLink from './Link' import AppLink from './Link'
import FixiOSBug from './FixiOSBug' import FixiOSBug from './FixiOSBug'
...@@ -98,7 +98,7 @@ export default { ...@@ -98,7 +98,7 @@ export default {
return path.resolve(this.basePath, routePath) return path.resolve(this.basePath, routePath)
}, },
isExternalLink(routePath) { isExternalLink(routePath) {
return validateURL(routePath) return isExternal(routePath)
}, },
generateTitle generateTitle
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册