All files / src/cli-validator/utils preprocessFile.js

100% Statements 9/9
100% Branches 0/0
100% Functions 1/1
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 2212x           50x 50x 50x       50x 50x 50x     50x   50x    
module.exports = function(originalFile) {
  let processedFile;
 
  // replace all tabs characters (\t) in the original file with 2 spaces
  // for whatever reason, the `getLineNumberForPath` module will crash if
  // the swagger contains any tab characters
  const tabExpression = /\t/g;
  const twoSpaces = '  ';
  processedFile = originalFile.replace(tabExpression, twoSpaces);
 
  // sanitize all instances of a solidus preceded by 1 or more escape characters
  // the `yaml-js` package crashes if there is an escaped solidus
  const escapedSolidus = /\\+\//g;
  const solidus = '/';
  processedFile = processedFile.replace(escapedSolidus, solidus);
 
  // Another problematic character is #9d - replace with space
  processedFile = processedFile.replace(/\x9d/g, ' ');
 
  return processedFile;
};