提交 087467a2 编写于 作者: T Tiago Cerqueira 提交者: ULIVZ

feat: handle telephone links (#325)

上级 f4de1180
...@@ -9,13 +9,13 @@ ...@@ -9,13 +9,13 @@
v-else v-else
:href="link" :href="link"
class="nav-link" class="nav-link"
:target="isMailto(link) ? null : '_blank'" :target="isMailto(link) || isTel(link) ? null : '_blank'"
:rel="isMailto(link) ? null : 'noopener noreferrer'" :rel="isMailto(link) || isTel(link) ? null : 'noopener noreferrer'"
>{{ item.text }}</a> >{{ item.text }}</a>
</template> </template>
<script> <script>
import { isExternal, isMailto, ensureExt } from './util' import { isExternal, isMailto, isTel, ensureExt } from './util'
export default { export default {
props: { props: {
...@@ -30,7 +30,8 @@ export default { ...@@ -30,7 +30,8 @@ export default {
}, },
methods: { methods: {
isExternal, isExternal,
isMailto isMailto,
isTel
} }
} }
</script> </script>
export const hashRE = /#.*$/ export const hashRE = /#.*$/
export const extRE = /\.(md|html)$/ export const extRE = /\.(md|html)$/
export const endingSlashRE = /\/$/ export const endingSlashRE = /\/$/
export const outboundRE = /^(https?:|mailto:)/ export const outboundRE = /^(https?:|mailto:|tel:)/
export function normalize (path) { export function normalize (path) {
return path return path
...@@ -24,6 +24,10 @@ export function isMailto (path) { ...@@ -24,6 +24,10 @@ export function isMailto (path) {
return /^mailto:/.test(path) return /^mailto:/.test(path)
} }
export function isTel (path) {
return /^tel:/.test(path)
}
export function ensureExt (path) { export function ensureExt (path) {
if (isExternal(path)) { if (isExternal(path)) {
return path return path
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册