From 2842c366e8653adb2a8caa87fc1cef13d929084f Mon Sep 17 00:00:00 2001 From: zouhang Date: Fri, 2 Jul 2021 09:31:10 +0800 Subject: [PATCH] feat: ignore the handling of http links --- src/client/app/utils.ts | 6 ++++-- src/shared/shared.ts | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/client/app/utils.ts b/src/client/app/utils.ts index f6438cc17a83..4879f7abc28a 100644 --- a/src/client/app/utils.ts +++ b/src/client/app/utils.ts @@ -1,5 +1,5 @@ import { siteDataRef } from './data' -import { inBrowser } from '../shared' +import { inBrowser, EXTERNAL_URL_RE } from '../shared' export { inBrowser } @@ -11,7 +11,9 @@ export function joinPath(base: string, path: string): string { } export function withBase(path: string) { - return joinPath(siteDataRef.value.base, path) + return EXTERNAL_URL_RE.test(path) + ? path + : joinPath(siteDataRef.value.base, path) } /** diff --git a/src/shared/shared.ts b/src/shared/shared.ts index c7ce172cf158..302fa31284ba 100644 --- a/src/shared/shared.ts +++ b/src/shared/shared.ts @@ -8,6 +8,8 @@ export type { Header } from '../../types/shared' +export const EXTERNAL_URL_RE = /^https?:/i + export const inBrowser = typeof window !== 'undefined' function findMatchRoot(route: string, roots: string[]) {