Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 82e037e

Browse files
fix: query params with same keys are added to the collection
BREAKING CHANGE: Query params on a router link with the same key are no longer overwriting the last value. Instead they are added to an array.
1 parent 3076885 commit 82e037e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

‎projects/testing-library/src/lib/testing-library.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,14 @@ export async function render<SutType, WrapperType = SutType>(
130130
const queryParams = params
131131
? params.split('&').reduce((qp, q) => {
132132
const [key, value] = q.split('=');
133-
// TODO(Breaking): group same keys qp[key] ? [...qp[key], value] : value
134-
qp[key] = value;
133+
const currentValue = qp[key];
134+
if (typeof currentValue === 'undefined') {
135+
qp[key] = value;
136+
} else if (Array.isArray(currentValue)) {
137+
qp[key] = [...currentValue, value];
138+
} else {
139+
qp[key] = [currentValue, value];
140+
}
135141
return qp;
136142
}, {})
137143
: undefined;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /