Skip to content

Update plainify regex to work with numbers#6

Open
wbio wants to merge 1 commit intoflowbe:masterfrom
wbio:plainify-regex
Open

Update plainify regex to work with numbers#6
wbio wants to merge 1 commit intoflowbe:masterfrom
wbio:plainify-regex

Conversation

@wbio
Copy link
Copy Markdown

@wbio wbio commented Oct 7, 2021

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.

Here's the old RegEx and here's the new RegEx.

@flowbe
Copy link
Copy Markdown
Owner

flowbe commented Feb 3, 2022

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants