Skip to content

Commit

Permalink
feat: handle telephone links (#325)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tiago Cerqueira authored and ulivz committed May 2, 2018
1 parent f4de118 commit 087467a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 5 additions & 4 deletions lib/default-theme/NavLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
v-else
:href="link"
class="nav-link"
:target="isMailto(link) ? null : '_blank'"
:rel="isMailto(link) ? null : 'noopener noreferrer'"
:target="isMailto(link) || isTel(link) ? null : '_blank'"
:rel="isMailto(link) || isTel(link) ? null : 'noopener noreferrer'"
>{{ item.text }}</a>
</template>

<script>
import { isExternal, isMailto, ensureExt } from './util'
import { isExternal, isMailto, isTel, ensureExt } from './util'
export default {
props: {
Expand All @@ -30,7 +30,8 @@ export default {
},
methods: {
isExternal,
isMailto
isMailto,
isTel
}
}
</script>
6 changes: 5 additions & 1 deletion lib/default-theme/util.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const hashRE = /#.*$/
export const extRE = /\.(md|html)$/
export const endingSlashRE = /\/$/
export const outboundRE = /^(https?:|mailto:)/
export const outboundRE = /^(https?:|mailto:|tel:)/

export function normalize (path) {
return path
Expand All @@ -24,6 +24,10 @@ export function isMailto (path) {
return /^mailto:/.test(path)
}

export function isTel (path) {
return /^tel:/.test(path)
}

export function ensureExt (path) {
if (isExternal(path)) {
return path
Expand Down

0 comments on commit 087467a

Please sign in to comment.