Skip to content

Commit f5a1e4f

Browse files
committed
Always send match=strict in US Street API requests
Previously the SDK suppressed the match parameter when set to "strict", relying on the API's default behavior. Now match is always sent explicitly, aligning with the Go SDK behavior.
1 parent ca218a6 commit f5a1e4f

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

src/util/buildUsStreetInputData.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ export default function buildUsStreetInputData(lookup: Lookup): Record<string, s
1414
effectiveMatch = "enhanced";
1515
}
1616

17-
// If match is "strict", don't send match parameter
18-
if (effectiveMatch === "strict") {
19-
effectiveMatch = undefined;
20-
}
21-
2217
// For "enhanced" match mode, set default candidates to 5 if not specified
2318
if (effectiveMatch === "enhanced" && !effectiveCandidates) {
2419
effectiveCandidates = 5;

tests/us_street/test_Client.ts

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,22 +77,23 @@ describe("A US Street client", function () {
7777
expect(mockSender.request.parameters).to.deep.equal(expectedParameters);
7878
});
7979

80-
it("sends no match or candidates when match type is strict.", function () {
80+
it("sends match=strict when match type is strict.", function () {
8181
let mockSender = new MockSender();
8282
const client = new Client(mockSender);
8383
let lookup = new Lookup();
8484
lookup.street = "123 Main St";
8585
lookup.match = "strict";
8686
let expectedParameters = {
8787
street: "123 Main St",
88+
match: "strict",
8889
};
8990

9091
client.send(lookup);
9192

9293
expect(mockSender.request.parameters).to.deep.equal(expectedParameters);
9394
});
9495

95-
it("sends candidates but not match when match is strict with explicit candidates.", function () {
96+
it("sends match=strict with explicit candidates.", function () {
9697
let mockSender = new MockSender();
9798
const client = new Client(mockSender);
9899
let lookup = new Lookup();
@@ -102,6 +103,7 @@ describe("A US Street client", function () {
102103
let expectedParameters = {
103104
street: "123 Main St",
104105
candidates: 3,
106+
match: "strict",
105107
};
106108

107109
client.send(lookup);
@@ -203,6 +205,38 @@ describe("A US Street client", function () {
203205
expect(mockSender.request.parameters).to.deep.equal(expectedParameters);
204206
});
205207

208+
it("sends match=strict in batch mode.", function () {
209+
let mockSender = new MockSender();
210+
const client = new Client(mockSender);
211+
let batch = new Batch();
212+
let lookup1 = new Lookup();
213+
lookup1.street = "123 Main St";
214+
lookup1.match = "strict";
215+
let lookup2 = new Lookup();
216+
lookup2.street = "456 Oak Ave";
217+
lookup2.match = "strict";
218+
batch.add(lookup1);
219+
batch.add(lookup2);
220+
221+
client.send(batch);
222+
223+
expect(mockSender.request.payload[0].match).to.equal("strict");
224+
expect(mockSender.request.payload[1].match).to.equal("strict");
225+
});
226+
227+
it("sends defaults in batch mode.", function () {
228+
let mockSender = new MockSender();
229+
const client = new Client(mockSender);
230+
let batch = new Batch();
231+
batch.add(new Lookup());
232+
batch.add(new Lookup());
233+
234+
client.send(batch);
235+
236+
expect(mockSender.request.payload[0].match).to.equal("enhanced");
237+
expect(mockSender.request.payload[0].candidates).to.equal(5);
238+
});
239+
206240
it("doesn't send an empty batch.", function () {
207241
let mockSender = new MockSender();
208242
const client = new Client(mockSender);

0 commit comments

Comments
 (0)