Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: skip external URLs in withBase #328

Merged
merged 1 commit into from
Jul 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/client/app/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { siteDataRef } from './data'
import { inBrowser } from '../shared'
import { inBrowser, EXTERNAL_URL_RE } from '../shared'

export { inBrowser }

Expand All @@ -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)
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/shared/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[]) {
Expand Down