Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

"Unbalanced" query parameters causes internal error. #2893

@appiepollo14

Description

@appiepollo14

Please avoid duplicates

Reproducible test case

https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAOwgYwNZwGZQiOByJNPAKGOQgQGd5LywBTOAXkRVQAo8ALGGMSgFwB6IQEMwwAHQBzYDC4BXAEaTyIPAEpicHbpn0YnIWFHzN23TskBHBfSgBPdgG84Fyzrwmo9BDDwC+ABuogA2dngANO4eXqI+fpIAjAH4GMBQ1FExOgC+Wh5wkj5goU4ATAAMlZFwrpQKyMj0lIJwMFB2cPkA3KSWxCJwAAIwlAC09AAeDMgwk1DYUMS0EAySACYQLQByEDAAolPA1OxaQA

Nock Version

V14

Node Version

v22.17.1

TypeScript Version

No response

What happened?

example url which fails:

http://example.test/path?parent=value&parent.1=first

I'm trying to use Nock to create a test for this valid url containing multiple query parameters. These contain dots and are "unbalanced". Meaning, not all are at the same nested level. The Nock tests fail internally with a message like: Cannot assign to read only property '1' of string 'value'

I believe this is caused as interceptor.js tries to matchQuery based on the common.dataEqual method. Which tries to parse the query part as an object, which is "unbalanced" in this case, so can't be turned into a valid object. IMHO we shouldn't expand the actual query as an object, as that is just a literal string.

I've only find the following issue, which let's me believe this might be seen as a feature, not a bug, but I'm not sure.

Would you be interested in contributing a fix?

  • yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions