rahulramesha / http2-express-bridge

wrapper for express app to work with http2 protocol
MIT License
31 stars 6 forks source link

Bug in isStringArray #7

Open artola opened 1 year ago

artola commented 1 year ago

I was reading the code to evaluate the usage, I found this line: https://github.com/rahulramesha/http2-express-bridge/blob/76b699e4385946b8c6fccacd45eac0577e24b66c/src/util.js#L7 The problem is that the return false does nothing more than finish the iteration and moving to the next element of the array.

    if (Array.isArray(arr)) {

        arr.forEach(item => {
           if(typeof item !== 'string'){
              return false  // <======= here
           }
        })

        return true
    }

Probably it was intended this optimised version that will stop asap:

    if (Array.isArray(arr)) {

        return arr.every(item => typeof item === 'string')

    }