Update index.js

This commit is contained in:
resetmylife 2021-07-20 15:40:37 +08:00 committed by GitHub
parent fff15b3907
commit e864ef7dba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -273,7 +273,7 @@ export function getTimeNum (post) {
let dateStr = post.frontmatter.date || post.lastUpdated || new Date()
let date = new Date(dateStr)
if (date == "Invalid Date" && dateStr) { // 修复new Date()在Safari下出现Invalid Date的问题
date = new Date(dateStr?.replace(/-/g, '/'))
date = new Date(dateStr.replace(/-/g, '/'))
}
return date.getTime()
}
@ -286,6 +286,6 @@ export function compareDate (a, b) {
// 将特殊符号编码应用于url
export function encodeUrl (str) {
str = str + ''
str = str?.replace(/ |((?=[\x21-\x7e]+)[^A-Za-z0-9])/g, '-')
str = str.replace(/ |((?=[\x21-\x7e]+)[^A-Za-z0-9])/g, '-')
return str
}