lib/helpers.js
function buildResourceHint (hint, asset, glob) {
  var as = ''

  if (hint === 'dns-prefetch' || hint === 'preconnect') {
    if (!urlMatch(asset, glob)) {
      return ''
    }

    asset = urlParse(asset)
    if (isDuplicate(asset, true)) {
      return ''
    }
  } else {
    if (!minimatch(asset, glob) || isDuplicate(asset)) {
      return ''
    }
    if (globMatch(asset, fonts)) {
      as += ' as="font"'
    } else if (isCSS(asset)) {
      as += ' as="style"'
    }
  }

  parsedAssets.push(asset)
  return `<link rel="${hint}" href="${asset}"${as} />`
}
function buildResourceHint (hint, asset, glob) {
  var as = ''

  if (hint === 'dns-prefetch' || hint === 'preconnect') {
    if (!urlMatch(asset, glob)) {
      return ''
    }

    asset = urlParse(asset)
    if (isDuplicate(asset, true)) {
      return ''
    }
  } else {
    if (!minimatch(asset, glob) || isDuplicate(asset)) {
      return ''
    }
    if (globMatch(asset, fonts)) {
      as += ' as="font"'
    } else if (isCSS(asset)) {
      as += ' as="style"'
    }
  }

  parsedAssets.push(asset)
  return `<link rel="${hint}" href="${asset}"${as} />`
}
function buildResourceHint ( hint , asset , glob ) { var as = '' if ( hint === 'dns-prefetch' || hint === 'preconnect' ) { if ( ! urlMatch ( asset , glob ) ) { return '' } asset = urlParse ( asset ) if ( isDuplicate ( asset , true ) ) { return '' } } else { if ( ! minimatch ( asset , glob ) || isDuplicate ( asset ) ) { return '' } if ( globMatch ( asset , fonts ) ) { as += ' as="font"' } else if ( isCSS ( asset ) ) { as += ' as="style"' } } parsedAssets . push ( asset ) return ` ${ hint } ${ asset } ${ as } ` }
Validate asset is desireable by user
Build resource hint if so
@param {string} hint
@param {string} asset
@param {string} glob
@return {string}
Validate asset is desireable by user Build resource hint if so