fix: skip external URLs in `withBase` (#328)

pull/332/head
hangzou 3 years ago committed by GitHub
parent 8597f268cc
commit 53bb961a92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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)
}
/**

@ -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[]) {

Loading…
Cancel
Save