{"payload":{"feedbackUrl":"https://github.com/orgs/community/discussions/53140","repo":{"id":16112842,"defaultBranch":"master","name":"json-to-go","ownerLogin":"mholt","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2014-01-21T18:11:13.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/1128849?v=4","public":true,"private":false,"isOrgOwned":false},"refInfo":{"name":"","listCacheKey":"v0:1390328341.0","currentOid":""},"activityList":{"items":[{"before":"e9233d6ba09833ffe657bfcd642bc184de029f0f","after":"086b5b22221d4b01d73e98913e5ed23e5a296839","ref":"refs/heads/master","pushedAt":"2023-11-03T03:53:19.000Z","pushType":"pr_merge","commitsCount":1,"pusher":{"login":"mholt","name":"Matt Holt","path":"/mholt","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/1128849?s=80&v=4"},"commit":{"message":"Fix greedy regex causing time.Time (#123)\n\nThe code in question is this small two lines.\r\n\r\nif (/\\d{4}-\\d\\d-\\d\\dT\\d\\d:\\d\\d:\\d\\d(\\.\\d+)?(\\+\\d\\d:\\d\\d|Z)/.test(val))\r\n return \"time.Time\";\r\n\r\nBut what happens if the string in the object contains a timestamp and a\r\nbunch of other junk meaning it isn't a time at all, but rather just a\r\nstring. There's a lot of valid use cases for this. For example, parsing\r\nsyslog...or something.\r\n\r\nlet val = \"2023-11-03T02:18:10+00:00 my name is bob\"\r\nif (/\\d{4}-\\d\\d-\\d\\dT\\d\\d:\\d\\d:\\d\\d(\\.\\d+)?(\\+\\d\\d:\\d\\d|Z)/.test(val)) {\r\n console.log(\"time.Time\");\r\n}\r\n> time.Time\r\n\r\nOh no. It also seems to function in this way when the extra junk is on\r\nthe other side of the timestamp.\r\n\r\nlet val = \"my name is bob 2023-11-03T02:18:10+00:00\"\r\nif (/\\d{4}-\\d\\d-\\d\\dT\\d\\d:\\d\\d:\\d\\d(\\.\\d+)?(\\+\\d\\d:\\d\\d|Z)/.test(val)) {\r\n console.log(\"time.Time\");\r\n}\r\n> time.Time\r\n\r\nThat's no fun. This is easy to overlook, and luckily it's a simple fix.\r\n\r\nlet val = \"2023-11-03T02:18:10+00:00 my name is bob\"\r\nif (/^\\d{4}-\\d\\d-\\d\\dT\\d\\d:\\d\\d:\\d\\d(\\.\\d+)?(\\+\\d\\d:\\d\\d|Z)$/.test(val)) {\r\n console.log(\"time.Time\");\r\n} else {\r\n console.log(\"Fixed\")\r\n}\r\n> Fixed","shortMessageHtmlLink":"Fix greedy regex causing time.Time (#123)"}}],"hasNextPage":false,"hasPreviousPage":false,"activityType":"all","actor":null,"timePeriod":"all","sort":"DESC","perPage":30,"cursor":"djE6ks8AAAADpmhXDQA","startCursor":null,"endCursor":null}},"title":"Activity ยท mholt/json-to-go"}