src/wappalyzer.js
function addDetected(app, pattern, type, value, key) {
  app.detected = true;

  // Set confidence level
  app.confidence[`${type} ${key ? `${key} ` : ''}${pattern.regex}`] = pattern.confidence === undefined ? 100 : parseInt(pattern.confidence, 10);

  // Detect version number
  if (pattern.version) {
    const versions = [];
    const matches = pattern.regex.exec(value);

    let { version } = pattern;

    if (matches) {
      matches.forEach((match, i) => {
        // Parse ternary operator
        const ternary = new RegExp(`\\\\${i}\\?([^:]+):(.*)$`).exec(version);

        if (ternary && ternary.length === 3) {
          version = version.replace(ternary[0], match ? ternary[1] : ternary[2]);
        }

        // Replace back references
        version = version.trim().replace(new RegExp(`\\\\${i}`, 'g'), match || '');
      });

      if (version && versions.indexOf(version) === -1) {
        versions.push(version);
      }

      if (versions.length) {
        // Use the longest detected version number
        app.version = versions.reduce((a, b) => (a.length > b.length ? a : b));
      }
    }
  }
}
function addDetected(app, pattern, type, value, key) {
  app.detected = true;

  // Set confidence level
  app.confidence[`${type} ${key ? `${key} ` : ''}${pattern.regex}`] = pattern.confidence === undefined ? 100 : parseInt(pattern.confidence, 10);

  // Detect version number
  if (pattern.version) {
    const versions = [];
    const matches = pattern.regex.exec(value);

    let { version } = pattern;

    if (matches) {
      matches.forEach((match, i) => {
        // Parse ternary operator
        const ternary = new RegExp(`\\\\${i}\\?([^:]+):(.*)$`).exec(version);

        if (ternary && ternary.length === 3) {
          version = version.replace(ternary[0], match ? ternary[1] : ternary[2]);
        }

        // Replace back references
        version = version.trim().replace(new RegExp(`\\\\${i}`, 'g'), match || '');
      });

      if (version && versions.indexOf(version) === -1) {
        versions.push(version);
      }

      if (versions.length) {
        // Use the longest detected version number
        app.version = versions.reduce((a, b) => (a.length > b.length ? a : b));
      }
    }
  }
}
function addDetected ( app , pattern , type , value , key ) { app . detected = true ; // Set confidence level app . confidence [ ` ${ type } ${ key ? ` ${ key } ` : '' } ${ pattern . regex } ` ] = pattern . confidence === undefined ? 100 : parseInt ( pattern . confidence , 10 ) ; // Detect version number if ( pattern . version ) { const versions = [ ] ; const matches = pattern . regex . exec ( value ) ; let { version } = pattern ; if ( matches ) { matches . forEach ( ( match , i ) => { // Parse ternary operator const ternary = new RegExp ( ` \\ \\ ${ i } \\ ` ) . exec ( version ) ; if ( ternary && ternary . length === 3 ) { version = version . replace ( ternary [ 0 ] , match ? ternary [ 1 ] : ternary [ 2 ] ) ; } // Replace back references version = version . trim ( ) . replace ( new RegExp ( ` \\ \\ ${ i } ` , 'g' ) , match || '' ) ; } ) ; if ( version && versions . indexOf ( version ) === - 1 ) { versions . push ( version ) ; } if ( versions . length ) { // Use the longest detected version number app . version = versions . reduce ( ( a , b ) => ( a . length > b . length ? a : b ) ) ; } } } }
Mark application as detected, set confidence and version
Mark application as detected set confidence and version