Fixed favicon not being loaded from url.

This commit is contained in:
SamTV12345 2024-01-20 23:07:38 +01:00
parent 1a61994c61
commit 29c81e3edf
2 changed files with 16 additions and 0 deletions

View file

@ -43,6 +43,16 @@ exports.expressPreSession = async (hookName, {app}) => {
app.get('/favicon.ico', (req, res, next) => {
(async () => {
/*
If this is a url we simply redirect to that one.
*/
if (settings.favicon.startsWith('http')) {
res.redirect(settings.favicon);
res.send();
return;
}
const fns = [
...(settings.favicon ? [path.resolve(settings.root, settings.favicon)] : []),
path.join(settings.root, 'src', 'static', 'skins', settings.skinName, 'favicon.ico'),

View file

@ -51,6 +51,12 @@ describe(__filename, function () {
assert(gotIcon.equals(wantCustomIcon));
});
it('uses custom favicon from url', async function () {
settings.favicon = 'https://etherpad.org/favicon.ico';
await agent.get('/favicon.ico')
.expect(302);
});
it('uses custom favicon if set (absolute pathname)', async function () {
settings.favicon = path.join(__dirname, 'favicon-test-custom.png');
assert(path.isAbsolute(settings.favicon));