Skip to content

Commit 53bb961

Browse files
fix: skip external URLs in withBase (#328)
1 parent 8597f26 commit 53bb961

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/client/app/utils.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { siteDataRef } from './data'
2-
import { inBrowser } from '../shared'
2+
import { inBrowser, EXTERNAL_URL_RE } from '../shared'
33

44
export { inBrowser }
55

@@ -11,7 +11,9 @@ export function joinPath(base: string, path: string): string {
1111
}
1212

1313
export function withBase(path: string) {
14-
return joinPath(siteDataRef.value.base, path)
14+
return EXTERNAL_URL_RE.test(path)
15+
? path
16+
: joinPath(siteDataRef.value.base, path)
1517
}
1618

1719
/**

src/shared/shared.ts

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ export type {
88
Header
99
} from '../../types/shared'
1010

11+
export const EXTERNAL_URL_RE = /^https?:/i
12+
1113
export const inBrowser = typeof window !== 'undefined'
1214

1315
function findMatchRoot(route: string, roots: string[]) {

0 commit comments

Comments
 (0)