Skip to content

Commit

Permalink
fix(plugins/rtf-to-txt): remove metadata comments from beginning of file
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Dec 1, 2021
1 parent b6dee34 commit 4c5095f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/plugins/rtf-to-txt/index.js
Expand Up @@ -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
Expand Down

0 comments on commit 4c5095f

Please sign in to comment.