AndiDittrich / NodeMCU-Tool

:wrench: Upload + Manage Lua files on NodeMCU
https://www.npmjs.com/package/nodemcu-tool
MIT License
310 stars 54 forks source link

fix: The includes() method is case sensitive. #62

Closed hanfengcan closed 5 years ago

hanfengcan commented 5 years ago

The includes() method is case sensitive.

fix the No Connected Devices found | Total: 0 when the letter mismatch

the effect

image

AndiDittrich commented 5 years ago

thanks @hanfengcan

but the term item.vendorId && item.vendorId.toUpperCase() doesn't make sense

hanfengcan commented 5 years ago

I don't understand why. I have 2 virtual port which there have not vendorId.

the vendorId maybe undefined, so I try item.vendorId && item.vendorId.toUpperCase()

AndiDittrich commented 5 years ago

the expression && is a boolean comparison

using it together with strings mean something like "if item.vendorId exists AND item.vendorId.toUpperCase() exists". exists means "not null, not undefined"

includes((item.vendorId || '').toUpperCase()) should work

edit: sry...this construct should work in js....

hanfengcan commented 5 years ago

yes, I tested the code. when the vendorId is undefined. the item.vendorId.toUpperCase() will throw error.

this is why I used item.vendorId && item.vendorId.toUpperCase()

btw, code (item.vendorId || '').toUpperCase() looks more elegant 😄