Skip to content

Commit e8d9c3b

Browse files
committed
📦 yarn build
1 parent a228c2a commit e8d9c3b

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

‎packages/utils/dist/removeTrailingNewLine.d.ts.map‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/utils/dist/removeTrailingNewLine.js‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,16 @@ Object.defineProperty(exports, "__esModule", {
55
});
66
exports.removeTrailingNewLine = void 0;
77
var _SignPdfError = require("./SignPdfError");
8+
/**
9+
* Removes a trailing character if it is the one passed as the second parameter.
10+
* @param {Buffer} pdf
11+
* @param {string} character
12+
* @returns {Buffer}
13+
*/
814
const sliceLastChar = (pdf, character) => {
9-
const lastChar = pdf.slice(pdf.length - 1).toString();
15+
const lastChar = pdf.subarray(pdf.length - 1).toString();
1016
if (lastChar === character) {
11-
return pdf.slice(0, pdf.length - 1);
17+
return pdf.subarray(0, pdf.length - 1);
1218
}
1319
return pdf;
1420
};
@@ -27,8 +33,8 @@ const removeTrailingNewLine = pdf => {
2733
let output = pdf;
2834
output = sliceLastChar(output, '\n');
2935
output = sliceLastChar(output, '\r');
30-
const lastLine = output.slice(output.length - 6).toString();
31-
if (lastLine !== '\n%%EOF') {
36+
const lastLine = output.subarray(output.length - 6).toString();
37+
if (lastLine !== '\n%%EOF' && lastLine !== '\r%%EOF') {
3238
throw new _SignPdfError.SignPdfError('A PDF file must end with an EOF line.', _SignPdfError.SignPdfError.TYPE_PARSE);
3339
}
3440
return output;

0 commit comments

Comments
 (0)