lib/helpers.js
function isDuplicate (assetToCheck, isHost) {
  if (parsedAssets.length <= 0) {
    return false
  }
  return ~parsedAssets.findIndex(function (asset) {
    if (isHost) {
      //  We don't want to preconnect twice, eh?
      return asset.split('//')[1] === assetToCheck.split('//')[1]
    }
    return asset === assetToCheck
  })
}
function isDuplicate (assetToCheck, isHost) {
  if (parsedAssets.length <= 0) {
    return false
  }
  return ~parsedAssets.findIndex(function (asset) {
    if (isHost) {
      //  We don't want to preconnect twice, eh?
      return asset.split('//')[1] === assetToCheck.split('//')[1]
    }
    return asset === assetToCheck
  })
}
function isDuplicate ( assetToCheck , isHost ) { if ( parsedAssets . length <= 0 ) { return false } return ~ parsedAssets . findIndex ( function ( asset ) { if ( isHost ) { //  We don't want to preconnect twice, eh? return asset . split ( '//' ) [ 1 ] === assetToCheck . split ( '//' ) [ 1 ] } return asset === assetToCheck } ) }
Checking duplicates is necessary for dns-prefetch and prefetch
resource hints since the same web page could have multiple assets
from the same external host, but we only want to dns-prefetch an
external host once.
 
Check for duplicates in parsedAssets helper array
@param {string} assetToCheck
@param {boolean} isHost
Checking duplicates is necessary for dns - prefetch and prefetch resource hints since the same web page could have multiple assets from the same external host but we only want to dns - prefetch an external host once . Check for duplicates in parsedAssets helper array