Skip to content

Commit

Permalink
feat: 完善冒号删除功能,删除中文冒号、“秒”字,如果没有空格则补上空格
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuiffy committed Mar 3, 2023
1 parent e74b082 commit 2970c64
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions utils/extractTimestamp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,16 @@ export function extractTimestamp(matchResult: RegExpMatchArray) {
}

const content = matchResult[2];
const formattedContent = content?.startsWith(":")
? content.substring(1)
: content;
let formattedContent = content;
try {
formattedContent = (content && /^[::秒]/.test(content))
? content.substring(1)
: content;
formattedContent = (formattedContent && !/^ /.test(formattedContent))
? ' ' + formattedContent
: formattedContent;
}catch(e){
console.log('handle text after time error', e);
}
return { timestamp, formattedContent };
}

0 comments on commit 2970c64

Please sign in to comment.