diff --git a/sdk/search/search-documents/CHANGELOG.md b/sdk/search/search-documents/CHANGELOG.md index 8d2c388e17e3..d97020e79fdd 100644 --- a/sdk/search/search-documents/CHANGELOG.md +++ b/sdk/search/search-documents/CHANGELOG.md @@ -29,6 +29,7 @@ - `SearchRequestOptions` - `SuggestRequest` - Fix discarded user-defined `onResponse` callback [#24479](https://github.com/Azure/azure-sdk-for-js/pull/24479) +- Fix ISO8601 deserialization [#25801](https://github.com/Azure/azure-sdk-for-js/pull/25801) ### Other Changes diff --git a/sdk/search/search-documents/src/serialization.ts b/sdk/search/search-documents/src/serialization.ts index b8b143263f5b..9042437d029c 100644 --- a/sdk/search/search-documents/src/serialization.ts +++ b/sdk/search/search-documents/src/serialization.ts @@ -3,7 +3,7 @@ import GeographyPoint from "./geographyPoint"; -const ISO8601DateRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?Z$/i; +const ISO8601DateRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?Z$/i; const GeoJSONPointTypeName = "Point"; const WorldGeodeticSystem1984 = "EPSG:4326"; // See https://epsg.io/4326 diff --git a/sdk/search/search-documents/test/internal/serialization.spec.ts b/sdk/search/search-documents/test/internal/serialization.spec.ts index 0b9545acc4ae..092973935e7b 100644 --- a/sdk/search/search-documents/test/internal/serialization.spec.ts +++ b/sdk/search/search-documents/test/internal/serialization.spec.ts @@ -116,6 +116,11 @@ describe("serialization.deserialize", function () { assert.deepEqual(result, { a: new Date(Date.UTC(1975, 3, 4)) }); }); + it("Date with truncated ms field", function () { + const result = deserialize({ a: "1975-04-04T00:00:00.0Z" }); + assert.deepEqual(result, { a: new Date(Date.UTC(1975, 3, 4)) }); + }); + it("doesn't deserialize as Date if text before", function () { const value = "before 1975-04-04T00:00:00.000Z"; const result = deserialize({ a: value });