Skip to content

Commit

Permalink
dedupe prefetchAs
Browse files Browse the repository at this point in the history
  • Loading branch information
Timer committed Feb 16, 2020
1 parent 2643285 commit 6a25c93
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/next/client/page-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ export default class PageLoader {
prefetchAs(asPath) {
asPath = normalizeRoute(asPath)
return this.promisedSsgManifest.then(
m =>
(m, _href) =>
m.some(r => r.test(asPath)) &&
appendLink(
`${this.assetPrefix}/_next/data/${this.buildId}${
asPath === '/' ? '/index' : asPath
}.json`,
relPrefetch,
'fetch'
)
((_href = `${this.assetPrefix}/_next/data/${this.buildId}${
asPath === '/' ? '/index' : asPath
}.json`),
!document.querySelector(
`link[rel="${relPrefetch}"][href^="${_href}"]`
)) &&
appendLink(_href, relPrefetch, 'fetch')
)
}

Expand Down

0 comments on commit 6a25c93

Please sign in to comment.