TheQwertiest / foo_spider_monkey_panel

foobar2000 component that allows to use JavaScript to create CUI/DUI panels
https://theqwertiest.github.io/foo_spider_monkey_panel/
MIT License
274 stars 21 forks source link

fb.GetQueryItems(fb.GetLibraryItems(), null) #196

Open regorxxx opened 1 year ago

regorxxx commented 1 year ago

Blank panel: console.log(fb.GetQueryItems(fb.GetLibraryItems(), null))

Will return any track with "null" on title, album, etc. instead of throwing an error or returning nothing (like passing undefined)). Null should not be parsed as a string in any case.

regorxxx commented 1 year ago
console.log('null', fb.GetQueryItems(fb.GetLibraryItems(), null))
console.log('""', fb.GetQueryItems(fb.GetLibraryItems(), ""))
console.log('void(0)', fb.GetQueryItems(fb.GetLibraryItems(), void(0)))
console.log('{}', fb.GetQueryItems(fb.GetLibraryItems(), {}))
console.log('Boolean', fb.GetQueryItems(fb.GetLibraryItems(), true))

null FbMetadbHandleList {Count=1, ...} "" FbMetadbHandleList {Count=0, ...} void(0) FbMetadbHandleList {Count=0, ...} {} FbMetadbHandleList {Count=0, ...} Boolean FbMetadbHandleList {Count=133, ...}

Well the conversion does affect other types... boolean values being converted to string 'true'/'false', etc.

Considering the recommended practice is to wrap the GetQueryItems method with try/catch to check for invalid queries... if those use-cases don't throw, it's a call for problems.