Skip to content

Commit 0460829

Browse files
authored
make isRFC3339_ISO6801() require string argument (#33)
1 parent 608c1b8 commit 0460829

6 files changed

Lines changed: 12 additions & 10 deletions

File tree

dist/module.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/module.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
{ "name": "GitHub Security Advisories", "path": "img/github_security_advisories.png"}
2626
],
2727
"version": "1.1.3",
28-
"updated": "2020-10-20"
28+
"updated": "2020-11-03"
2929
},
3030

3131
"dependencies": {

src/DataSource.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export class DataSource extends DataSourceApi<MyQuery, MyDataSourceOptions> {
170170
}
171171
for (const fieldName in doc) {
172172
let t: FieldType = FieldType.string;
173-
if (fieldName === 'Time' || isRFC3339_ISO6801(doc[fieldName])) {
173+
if (fieldName === 'Time' || isRFC3339_ISO6801(String(doc[fieldName]))) {
174174
t = FieldType.time;
175175
} else if (_.isNumber(doc[fieldName])) {
176176
t = FieldType.number;

src/util.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ test('flatten function test', () => {
3939
test('RFC3339 and ISO8601 valid string test', () => {
4040
expect(isRFC3339_ISO6801('I am not a date but a string')).toBe(false);
4141
expect(isRFC3339_ISO6801('1234')).toBe(false);
42-
expect(isRFC3339_ISO6801(8)).toBe(false);
43-
expect(isRFC3339_ISO6801(null)).toBe(false);
42+
expect(isRFC3339_ISO6801(String(8))).toBe(false);
43+
expect(isRFC3339_ISO6801(String(null))).toBe(false);
4444
expect(isRFC3339_ISO6801('2020-06-01T00:00:00.000Z')).toBe(true);
4545
expect(isRFC3339_ISO6801('2020-06-01T00:00:00Z')).toBe(true);
46-
expect(isRFC3339_ISO6801(true)).toBe(false);
47-
expect(isRFC3339_ISO6801(0)).toBe(false);
48-
expect(isRFC3339_ISO6801(0.111111)).toBe(false);
46+
expect(isRFC3339_ISO6801(String(true))).toBe(false);
47+
expect(isRFC3339_ISO6801(String(0))).toBe(false);
48+
expect(isRFC3339_ISO6801(String(Number.MAX_SAFE_INTEGER))).toBe(false);
49+
expect(isRFC3339_ISO6801(String(0.111111))).toBe(false);
50+
expect(isRFC3339_ISO6801(String(1603810963000))).toBe(false);
4951
});

src/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export function flatten<T extends Record<string, any>>(object: T, path: string |
88
}, {} as T);
99
}
1010

11-
export function isRFC3339_ISO6801(str: any): boolean {
11+
export function isRFC3339_ISO6801(str: string): boolean {
1212
let date = dateTime(str, ISO_8601);
1313
if (date.isValid()) {
1414
let iso = date.toISOString();

0 commit comments

Comments
 (0)