Skip to content

Commit

Permalink
fix: skip external URLs in withBase (vuejs#328)
Browse files Browse the repository at this point in the history
  • Loading branch information
zouhangwithsweet authored and YunYouJun committed Aug 30, 2021
1 parent 9f52bf1 commit e740fc2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
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

0 comments on commit e740fc2

Please sign in to comment.