Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Search GA] Fix ISO8601 deserialization #25802

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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