Skip to content

Commit

Permalink
[Search GA] Fix ISO8601 deserialization (#25802)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgetu authored May 9, 2023
1 parent 99e74d6 commit 2f4fc50
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions sdk/search/search-documents/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release History

## 11.3.2 (2023-05-09)

### Bugs Fixed

- Fix ISO8601 deserialization [#25802](https://github.com/Azure/azure-sdk-for-js/pull/25802)

## 11.3.1 (2022-11-18)

### Bugs Fixed
Expand Down
2 changes: 1 addition & 1 deletion sdk/search/search-documents/src/serialization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ describe("serialization.deserialize", () => {
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", () => {
const value = "before 1975-04-04T00:00:00.000Z";
const result = deserialize({ a: value });
Expand Down

0 comments on commit 2f4fc50

Please sign in to comment.