Skip to content

Commit

Permalink
optimization: hash lookup is faster than in-array check (github#23079)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbe authored Nov 23, 2021
1 parent feb0318 commit 0eb15bc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/render-content/plugins/rewrite-local-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import removeFPTFromPath from '../../remove-fpt-from-path.js'
import readJsonFile from '../../read-json-file.js'
const supportedVersions = Object.keys(allVersions)
const supportedPlans = Object.values(allVersions).map((v) => v.plan)
const externalRedirects = Object.keys(readJsonFile('./lib/redirects/external-sites.json'))
const externalRedirects = readJsonFile('./lib/redirects/external-sites.json')

// Matches any <a> tags with an href that starts with `/`
const matcher = (node) =>
Expand Down Expand Up @@ -41,7 +41,7 @@ function getNewHref(node, languageCode, version) {
// Exceptions to link rewriting
if (href.startsWith('/assets')) return
if (href.startsWith('/public')) return
if (externalRedirects.includes(href)) return
if (href in externalRedirects) return

let newHref = href
// If the link has a hardcoded plan or version in it, do not update other than adding a language code
Expand Down

0 comments on commit 0eb15bc

Please sign in to comment.