index.js
function matchLicense (licenseString) {
  // Find all textual matches on license text.
  var normalized = normalizeText(licenseString)
  var matchingLicenses = []

  var license

  // Check matches of normalized license content against signatures.
  for (var i = 0; i < licenses.length; i++) {
    license = licenses[i]
    var match = false
    for (var j = 0; j < license.signatures.length; j++) {
      if (normalized.indexOf(license.signatures[j]) >= 0) {
        match = true
        break
      }
    }
    if (match) {
      matchingLicenses.push(license)
    }
  }
  // For single-line license, check if it's a known license id.
  if (matchingLicenses.length === 0 && !/[\n\f\r]/.test(licenseString) && licenseString.length < 100) {
    var licenseName = normalizeText(licenseString)
    // If there's an extra "license" on the end of the name, drop it ("MIT License" -> "MIT").
    license = licenseIndex[licenseName] || licenseIndex[licenseName.replace(/ licen[sc]e$/, '')]
    if (!license) {
      license = {name: licenseName, id: null}
    }
    matchingLicenses.push(license)
  }
  if (matchingLicenses.length === 0) {
    return null
  }
  if (matchingLicenses.length > 1) {
    console.warn('Multiple matching licenses: ' + matchingLicenses.length, [licenseString, matchingLicenses])
  }
  return matchingLicenses[0]
}
function matchLicense (licenseString) {
  // Find all textual matches on license text.
  var normalized = normalizeText(licenseString)
  var matchingLicenses = []

  var license

  // Check matches of normalized license content against signatures.
  for (var i = 0; i < licenses.length; i++) {
    license = licenses[i]
    var match = false
    for (var j = 0; j < license.signatures.length; j++) {
      if (normalized.indexOf(license.signatures[j]) >= 0) {
        match = true
        break
      }
    }
    if (match) {
      matchingLicenses.push(license)
    }
  }
  // For single-line license, check if it's a known license id.
  if (matchingLicenses.length === 0 && !/[\n\f\r]/.test(licenseString) && licenseString.length < 100) {
    var licenseName = normalizeText(licenseString)
    // If there's an extra "license" on the end of the name, drop it ("MIT License" -> "MIT").
    license = licenseIndex[licenseName] || licenseIndex[licenseName.replace(/ licen[sc]e$/, '')]
    if (!license) {
      license = {name: licenseName, id: null}
    }
    matchingLicenses.push(license)
  }
  if (matchingLicenses.length === 0) {
    return null
  }
  if (matchingLicenses.length > 1) {
    console.warn('Multiple matching licenses: ' + matchingLicenses.length, [licenseString, matchingLicenses])
  }
  return matchingLicenses[0]
}
function matchLicense ( licenseString ) { // Find all textual matches on license text. var normalized = normalizeText ( licenseString ) var matchingLicenses = [ ] var license // Check matches of normalized license content against signatures. for ( var i = 0 ; i < licenses . length ; i ++ ) { license = licenses [ i ] var match = false for ( var j = 0 ; j < license . signatures . length ; j ++ ) { if ( normalized . indexOf ( license . signatures [ j ] ) >= 0 ) { match = true break } } if ( match ) { matchingLicenses . push ( license ) } } // For single-line license, check if it's a known license id. if ( matchingLicenses . length === 0 && ! / [\n\f\r] / . test ( licenseString ) && licenseString . length < 100 ) { var licenseName = normalizeText ( licenseString ) // If there's an extra "license" on the end of the name, drop it ("MIT License" -> "MIT"). license = licenseIndex [ licenseName ] || licenseIndex [ licenseName . replace ( /  licen[sc]e$ / , '' ) ] if ( ! license ) { license = { name : licenseName , id : null } } matchingLicenses . push ( license ) } if ( matchingLicenses . length === 0 ) { return null } if ( matchingLicenses . length > 1 ) { console . warn ( 'Multiple matching licenses: ' + matchingLicenses . length , [ licenseString , matchingLicenses ] ) } return matchingLicenses [ 0 ] }
Match a license body or license id against known set of licenses.
Match a license body or license id against known set of licenses .