Skip to content

Commit

Permalink
fix: don't add base to external urls while preloading (#1045)
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd committed Jul 22, 2022
1 parent c476bbd commit 7295033
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/node/build/render.ts
Expand Up @@ -10,7 +10,8 @@ import {
PageData,
createTitle,
notFoundPageData,
mergeHead
mergeHead,
EXTERNAL_URL_RE
} from '../shared'
import { slash } from '../utils/slash'
import { SiteConfig, resolveSiteDataByRoute } from '../config'
Expand Down Expand Up @@ -104,13 +105,17 @@ export async function renderPage(

const preloadLinksString = preloadLinks
.map((file) => {
return `<link rel="modulepreload" href="${siteData.base}${file}">`
return `<link rel="modulepreload" href="${
EXTERNAL_URL_RE.test(file) ? '' : siteData.base // don't add base to external urls
}${file}">`
})
.join('\n ')

const prefetchLinkString = prefetchLinks
.map((file) => {
return `<link rel="prefetch" href="${siteData.base}${file}">`
return `<link rel="prefetch" href="${
EXTERNAL_URL_RE.test(file) ? '' : siteData.base // don't add base to external urls
}${file}">`
})
.join('\n ')

Expand Down

0 comments on commit 7295033

Please sign in to comment.