From 2ccb58bdb5f464aebb991aa26fb4056c23354fd5 Mon Sep 17 00:00:00 2001
From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com>
Date: Fri, 8 Jul 2022 15:01:33 +0530
Subject: [PATCH] fix: support all url schemes
---
src/client/theme-default/components/VPButton.vue | 3 ++-
src/client/theme-default/components/VPLink.vue | 3 ++-
src/client/theme-default/support/utils.ts | 4 ++--
src/shared/shared.ts | 2 +-
4 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/client/theme-default/components/VPButton.vue b/src/client/theme-default/components/VPButton.vue
index 0f818d9a..714f3e0c 100644
--- a/src/client/theme-default/components/VPButton.vue
+++ b/src/client/theme-default/components/VPButton.vue
@@ -1,6 +1,7 @@
diff --git a/src/client/theme-default/support/utils.ts b/src/client/theme-default/support/utils.ts
index be2a39c8..5c31e6f0 100644
--- a/src/client/theme-default/support/utils.ts
+++ b/src/client/theme-default/support/utils.ts
@@ -1,15 +1,15 @@
import { ref } from 'vue'
import { withBase } from 'vitepress'
+import { EXTERNAL_URL_RE } from '../../shared'
export const HASH_RE = /#.*$/
export const EXT_RE = /(index)?\.(md|html)$/
-export const OUTBOUND_RE = /^[a-z]+:/i
const inBrowser = typeof window !== 'undefined'
const hashRef = ref(inBrowser ? location.hash : '')
export function isExternal(path: string): boolean {
- return OUTBOUND_RE.test(path)
+ return EXTERNAL_URL_RE.test(path)
}
export function throttleAndDebounce(fn: () => void, delay: number): () => void {
diff --git a/src/shared/shared.ts b/src/shared/shared.ts
index fa2e791f..959d470c 100644
--- a/src/shared/shared.ts
+++ b/src/shared/shared.ts
@@ -10,7 +10,7 @@ export type {
PageDataPayload
} from '../../types/shared'
-export const EXTERNAL_URL_RE = /^(https?|data):/i
+export const EXTERNAL_URL_RE = /^[a-z]+:/i
export const APPEARANCE_KEY = 'vitepress-theme-appearance'
// @ts-ignore