mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-05-01 12:43:08 -04:00
* the "position" attribute is always set to 0 when using an anchor for pagination, but it does not accurately reflect the position and thus we decided to remove the attribute from the resulting object for clarity * omit "canCalculateChanges" attribute when its value is "true", which is going to be the case in 100% of calls against Stalwart
39 lines
923 B
JavaScript
39 lines
923 B
JavaScript
import * as fs from 'fs'
|
|
import * as cheerio from 'cheerio'
|
|
import { stdin } from 'process'
|
|
|
|
process.on('unhandledRejection', (reason, promise) => {
|
|
console.error('Unhandled Rejection at:', promise, 'reason:', reason);
|
|
process.exit(1);
|
|
});
|
|
|
|
async function run() {
|
|
try {
|
|
const faviconFile = process.argv[2];
|
|
if (!faviconFile) {
|
|
throw new Error("No favicon file provided");
|
|
}
|
|
|
|
const favicon = fs.readFileSync(faviconFile).toString('base64');
|
|
|
|
let html = '';
|
|
for await (const chunk of stdin) {
|
|
html += chunk;
|
|
}
|
|
|
|
if (!html) {
|
|
throw new Error("No HTML received from stdin");
|
|
}
|
|
|
|
const $ = cheerio.load(html);
|
|
$('head').append(`<link rel="icon" href="data:image/png;base64,${favicon}">`);
|
|
|
|
process.stdout.write($.html() + "\n");
|
|
} catch (e) {
|
|
console.error(`Error occurred while post-processing HTML: ${e.message}`);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
run();
|