node-qbittorrent-api-v2
node-qbittorrent-api-v2 copied to clipboard
Update plainify regex to work with numbers
I was trying to update the global speed limit on qBittorrent (setGlobalDownloadLimit) and got a 400 error. I did some digging and it looks like the problem is in the RegEx within the plainify method that converts the parameters object to key/value pairs. Right now the RegEx is looking for values within quotes:
str = str.replace(/"([^"]*)":"([^"]*)",?/g, '$1=$2&')
Since the global speed limit requires a number (and therefore isn't surrounded by quotes in JSON), this doesn't get replaced and formatted and str winds up looking like "limit":10240000 rather than limit=10240000.
This PR makes the quotes around the field value optional so that both numbers and strings get captured and formatted correctly.
Hi @wbio, thank you for your contribution. I just merged another PR that changes the planify method. Can you let me know if this works correctly for you now or update your PR? Thanks!