Skip to content

Commit 5016e55

Browse files
committed
Simplify query-matcher-from-rule logic slightly
1 parent 612d639 commit 5016e55

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/model/rules/rule-creation.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,10 @@ function buildRequestMatchers(request: HtkRequest) {
129129
const urlParts = request.parsedUrl.toString().split('?');
130130
const path = urlParts[0];
131131

132-
const hasQuery = request.url.includes('?'); // Not just with parameters, but also trailing '?'
133-
const query = urlParts.slice(1).join('?');
132+
const hasQuery = urlParts.length > 1; // Not just with parameters, but also trailing '?'
134133
const queryMatcher = hasQuery
135134
? [new matchers.QueryMatcher(
136-
querystring.parse(query) as ({ [key: string]: string | string[] })
135+
querystring.parse(urlParts.slice(1).join('?')) as ({ [key: string]: string | string[] })
137136
)]
138137
: [];
139138

0 commit comments

Comments
 (0)