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?
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=firstI'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.jstries tomatchQuerybased on thecommon.dataEqualmethod. 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?