lib/helpers.js
function hasInsertionPoint (file) {
  var token = appOptions.pageToken

  if (token !== '' && String(file.contents).indexOf(token) > -1) {
    insertionPoint = 'token'
    return true
  } else if (token !== '' && token !== defaults.pageToken) {
    logger('Token not found in ' + file.relative)
  }

  var soup = new Soup(String(file.contents))

  // Append after metas
  soup.setInnerHTML('head > meta:last-of-type', function (oldHTML) {
    if (oldHTML !== null) {
      insertionPoint = 'meta'
      return oldHTML
    }
  })

  if (insertionPoint) {
    return true
  }

  // Else, prepend before links
  soup.setInnerHTML('head > link:first-of-type', function (oldHTML) {
    if (oldHTML !== null) {
      insertionPoint = 'link'
      return oldHTML
    }
  })

  if (insertionPoint) {
    return true
  }

  // Else, append to head
  soup.setInnerHTML('head', function (oldHTML) {
    if (oldHTML !== null) {
      insertionPoint = 'head'
      return oldHTML
    }
  })

  return insertionPoint
}
function hasInsertionPoint (file) {
  var token = appOptions.pageToken

  if (token !== '' && String(file.contents).indexOf(token) > -1) {
    insertionPoint = 'token'
    return true
  } else if (token !== '' && token !== defaults.pageToken) {
    logger('Token not found in ' + file.relative)
  }

  var soup = new Soup(String(file.contents))

  // Append after metas
  soup.setInnerHTML('head > meta:last-of-type', function (oldHTML) {
    if (oldHTML !== null) {
      insertionPoint = 'meta'
      return oldHTML
    }
  })

  if (insertionPoint) {
    return true
  }

  // Else, prepend before links
  soup.setInnerHTML('head > link:first-of-type', function (oldHTML) {
    if (oldHTML !== null) {
      insertionPoint = 'link'
      return oldHTML
    }
  })

  if (insertionPoint) {
    return true
  }

  // Else, append to head
  soup.setInnerHTML('head', function (oldHTML) {
    if (oldHTML !== null) {
      insertionPoint = 'head'
      return oldHTML
    }
  })

  return insertionPoint
}
function hasInsertionPoint ( file ) { var token = appOptions . pageToken if ( token !== '' && String ( file . contents ) . indexOf ( token ) > - 1 ) { insertionPoint = 'token' return true } else if ( token !== '' && token !== defaults . pageToken ) { logger ( 'Token not found in ' + file . relative ) } var soup = new Soup ( String ( file . contents ) ) // Append after metas soup . setInnerHTML ( 'head > meta:last-of-type' , function ( oldHTML ) { if ( oldHTML !== null ) { insertionPoint = 'meta' return oldHTML } } ) if ( insertionPoint ) { return true } // Else, prepend before links soup . setInnerHTML ( 'head > link:first-of-type' , function ( oldHTML ) { if ( oldHTML !== null ) { insertionPoint = 'link' return oldHTML } } ) if ( insertionPoint ) { return true } // Else, append to head soup . setInnerHTML ( 'head' , function ( oldHTML ) { if ( oldHTML !== null ) { insertionPoint = 'head' return oldHTML } } ) return insertionPoint }
Determine if file has a valid area to inject resource hints
@param {stream} file
Determine if file has a valid area to inject resource hints