Skip to content

Commit bd501eb

Browse files
committed
updates
1 parent 22a07d5 commit bd501eb

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

components/pdf4me/common/utils.mjs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function normalizeFilePath(path) {
88
}
99

1010
function checkForExtension(filename, ext = "pdf") {
11-
return filename.includes(`.${ext}`)
11+
return filename.endsWith(`.${ext}`)
1212
? filename
1313
: `${filename}.${ext}`;
1414
}
@@ -26,16 +26,19 @@ function downloadToTmp(response, filename) {
2626
}
2727

2828
function handleErrorMessage(error) {
29+
if (!error) {
30+
throw new ConfigurationError("Unknown error occurred");
31+
}
2932
let errorMessage = error.name;
30-
if (error.response && error.response.data) {
33+
if (error.response?.data) {
3134
const text = Buffer.from(error.response.data).toString("utf-8");
3235
try {
3336
errorMessage = JSON.stringify(JSON.parse(text));
3437
} catch (parseErr) {
3538
errorMessage = text;
3639
}
3740
}
38-
throw new ConfigurationError(`${errorMessage}`);
41+
throw new ConfigurationError(errorMessage);
3942
}
4043

4144
export default {

0 commit comments

Comments
 (0)