Skip to content

Commit

Permalink
feat(fixer): trailing char fixer simplification
Browse files Browse the repository at this point in the history
This shouldn't _but could (in theory) break_ some applications (even tho the test suite seems to suggest it's robust enough).
  • Loading branch information
Berkmann18 committed Jun 20, 2020
1 parent f0d172d commit 5899676
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/fixer.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@ const fixTrailingChar = ({ start, fixedData, verbose }) => {
const brokenLine = removeLinebreak(fixedData[targetLine]);
const fixedLine = brokenLine.replace(/(":\s*)[.,](\d*)/g, '$10.$2');
const unquotedWord = /(":\s*)(\S*)/g.exec(fixedLine);
if (unquotedWord) {
const NN = Number.isNaN(Number(unquotedWord[2]));
if (NN && !/([xbo][0-9a-fA-F]+)/.test(unquotedWord[2])) {
return quotify({ fixedData, targetLine, fixedLine, verbose });
}
if (!NN && !/\0([xbo][0-9a-fA-F]+)/.test(unquotedWord[2])) {
return numberify({ fixedData, targetLine, fixedLine, unquotedWord, verbose });
}
// if (unquotedWord === null) throw new Error('Unquoted word expected!');
const NN = Number.isNaN(Number(unquotedWord[2]));
if (NN && !/([xbo][0-9a-fA-F]+)/.test(unquotedWord[2])) {
return quotify({ fixedData, targetLine, fixedLine, verbose });
}
if (!NN && !/\0([xbo][0-9a-fA-F]+)/.test(unquotedWord[2])) {
return numberify({ fixedData, targetLine, fixedLine, unquotedWord, verbose });
}
let baseNumber = fixedLine.replace(/(":\s*)([xbo][0-9a-fA-F]*)/g, '$1"0$2"');
if (baseNumber !== fixedLine) {
Expand Down

0 comments on commit 5899676

Please sign in to comment.