Skip to content

Commit

Permalink
📦 yarn build
Browse files Browse the repository at this point in the history
  • Loading branch information
vbuch committed Jan 19, 2024
1 parent a228c2a commit e8d9c3b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/utils/dist/removeTrailingNewLine.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions packages/utils/dist/removeTrailingNewLine.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ Object.defineProperty(exports, "__esModule", {
});
exports.removeTrailingNewLine = void 0;
var _SignPdfError = require("./SignPdfError");
/**
* Removes a trailing character if it is the one passed as the second parameter.
* @param {Buffer} pdf
* @param {string} character
* @returns {Buffer}
*/
const sliceLastChar = (pdf, character) => {
const lastChar = pdf.slice(pdf.length - 1).toString();
const lastChar = pdf.subarray(pdf.length - 1).toString();
if (lastChar === character) {
return pdf.slice(0, pdf.length - 1);
return pdf.subarray(0, pdf.length - 1);
}
return pdf;
};
Expand All @@ -27,8 +33,8 @@ const removeTrailingNewLine = pdf => {
let output = pdf;
output = sliceLastChar(output, '\n');
output = sliceLastChar(output, '\r');
const lastLine = output.slice(output.length - 6).toString();
if (lastLine !== '\n%%EOF') {
const lastLine = output.subarray(output.length - 6).toString();
if (lastLine !== '\n%%EOF' && lastLine !== '\r%%EOF') {
throw new _SignPdfError.SignPdfError('A PDF file must end with an EOF line.', _SignPdfError.SignPdfError.TYPE_PARSE);
}
return output;
Expand Down

0 comments on commit e8d9c3b

Please sign in to comment.