Skip to content

Commit

Permalink
Merge pull request #8 from mcanam/refactor/parser/input_validation
Browse files Browse the repository at this point in the history
Improve input validation and error handling
  • Loading branch information
mcanam authored Apr 28, 2024
2 parents 0b93438 + d7602ed commit 2825b05
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ const ENHANCED_REGEX = /<\d{2}:\d{2}(.\d{2,})?>\s*[^\s|<]*/g;
* @returns {Object} parsed lrc data
*/
export default function parser(lrc) {
if (lrc == '' || !lrc.trim()) {
console.warn("[Liricle] LRC is empty.");
}

const output = {
tags : {},
lines: [],
enhanced: isEnhanced(lrc)
};

if (typeof lrc != 'string' || !lrc.trim()) {
console.warn("[Liricle] LRC is empty.");
return output;
}

const lines = lrc.split(/\r?\n/);

// parsing started
Expand Down

0 comments on commit 2825b05

Please sign in to comment.