[search-documents] Fix ISO8601 date regex (#10488)
* [search-documents] Fix ISO8601 date regex (#10486) * Add tests for dates with text before and after (#10486)
This commit is contained in:
Родитель
4ad346ad77
Коммит
f13a878c49
|
@ -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{3})?Z$/i;
|
||||
const GeoJSONPointTypeName = "Point";
|
||||
const WorldGeodeticSystem1984 = "EPSG:4326"; // See https://epsg.io/4326
|
||||
|
||||
|
|
|
@ -72,6 +72,24 @@ describe("serialization.deserialize", () => {
|
|||
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 });
|
||||
assert.deepEqual(result, { a: value });
|
||||
});
|
||||
|
||||
it("doesn't deserialize as Date if text after", () => {
|
||||
const value = "1975-04-04T00:00:00.000Z after";
|
||||
const result = deserialize({ a: value });
|
||||
assert.deepEqual(result, { a: value });
|
||||
});
|
||||
|
||||
it("doesn't deserialize as Date if text before and after", () => {
|
||||
const value = "before 1975-04-04T00:00:00.000Z after";
|
||||
const result = deserialize({ a: value });
|
||||
assert.deepEqual(result, { a: value });
|
||||
});
|
||||
|
||||
it("GeographyPoint", () => {
|
||||
const result: { location: GeographyPoint } = deserialize({
|
||||
location: {
|
||||
|
|
Загрузка…
Ссылка в новой задаче