Skip to content
Permalink
Browse files
fix(plugins/rtf-to-txt): remove metadata comments from beginning of file
  • Loading branch information
Fdawgs committed Dec 1, 2021
1 parent b6dee34 commit 4c5095f9fe63b42b729cf10d9bc1cd4a26abb83d
Showing with 5 additions and 5 deletions.
  1. +5 −5 src/plugins/rtf-to-txt/index.js
@@ -79,15 +79,15 @@ async function plugin(server, options) {
await fs.writeFile(tempFile, req.body);

try {
/**
* `fixUtf8` function replaces most common incorrectly converted
* Windows-1252 to UTF-8 results with HTML equivalents.
* Refer to https://www.i18nqa.com/debug/utf8-debug.html for more info.
*/
req.conversionResults.body = await unrtf.convert(
tempFile,
config.rtfToTxtOptions
);

// Remove metadata comments UnRTF adds to beginning of file
req.conversionResults.body = req.conversionResults.body
.replace(/^###(?:\s){0,3}.*?(?:-){1,17}/ms, "")
.trim();
} catch (err) {
/**
* UnRTF will throw if the .rtf file provided

0 comments on commit 4c5095f

Please sign in to comment.