@@ -21,10 +21,14 @@ const isPathString = computed(() => {
2121 return typeof props .path === ' string'
2222})
2323const isExternalLink = computed (() => {
24- return props .href ?.startsWith (' http' ) || (isPathString .value && (props .path as string ).startsWith (' http' ))
24+ return props .href ?.startsWith (' http' ) ||
25+ (isPathString .value && (props .path as string ).startsWith (' http' )) ||
26+ (typeof props .to === ' string' && (props .to as string ).startsWith (' http' ))
2527})
2628const isMailto = computed (() => {
27- return props .href ?.startsWith (' mailto' ) || (isPathString .value && (props .path as string ).startsWith (' mailto' ))
29+ return props .href ?.startsWith (' mailto' ) ||
30+ (isPathString .value && (props .path as string ).startsWith (' mailto' )) ||
31+ (typeof props .to === ' string' && (props .to as string ).startsWith (' mailto' ))
2832})
2933const is = computed (() => {
3034 if (props .button ) {
@@ -37,13 +41,13 @@ const actualHref = computed(() => {
3741 if (! isExternalLink .value && ! isMailto .value ) {
3842 return undefined
3943 }
40- return props .href !== undefined ? props .href : props .path
44+ return props .to ?? props .href ?? props .path
4145})
4246const actualTo = computed (() => {
4347 if (isExternalLink .value || isMailto .value ) {
4448 return undefined
4549 }
46- return props .to || props .path
50+ return props .to ?? props .path
4751})
4852const linkData = computed (() => {
4953 return actualTo .value ? { to: actualTo .value } : { href: actualHref .value }
0 commit comments