Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Dec 28, 2023
1 parent f5afb52 commit 75960b7
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/runtime/sitemap/urlset/normalise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,11 @@ export function normaliseDate(d: Date | string) {
if (typeof d === 'string') {
// we may have milliseconds at the end with a dot prefix like ".963745", we should remove this
d = d.replace(/\.\d+$/, '')
console.log('match', d, d.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/))
// we may have a value like this "2023-12-21T13:49:27", this needs to be converted to w3c datetime
// accept if they are already in the right format, accept small format too such as "2023-12-21"
if (d.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/) || d.match(/^\d{4}-\d{2}-\d{2}$/)) {
console.log('pass')
if (d.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/) || d.match(/^\d{4}-\d{2}-\d{2}$/))
return d
}

// otherwise we need to parse it
d = new Date(d)
// check for invalid date
Expand Down

0 comments on commit 75960b7

Please sign in to comment.