Fixed favicon not being loaded from url. (#6113)

* Fixed favicon not being loaded from url.

* Fixed tests.
This commit is contained in:
SamTV12345 2024-01-20 23:11:52 +01:00 committed by GitHub
parent 1a61994c61
commit 9e2c4bf781
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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) => { app.get('/favicon.ico', (req, res, next) => {
(async () => { (async () => {
/*
If this is a url we simply redirect to that one.
*/
if (settings.favicon && settings.favicon.startsWith('http')) {
res.redirect(settings.favicon);
res.send();
return;
}
const fns = [ const fns = [
...(settings.favicon ? [path.resolve(settings.root, settings.favicon)] : []), ...(settings.favicon ? [path.resolve(settings.root, settings.favicon)] : []),
path.join(settings.root, 'src', 'static', 'skins', settings.skinName, 'favicon.ico'), path.join(settings.root, 'src', 'static', 'skins', settings.skinName, 'favicon.ico'),

View file

@ -51,6 +51,12 @@ describe(__filename, function () {
assert(gotIcon.equals(wantCustomIcon)); 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 () { it('uses custom favicon if set (absolute pathname)', async function () {
settings.favicon = path.join(__dirname, 'favicon-test-custom.png'); settings.favicon = path.join(__dirname, 'favicon-test-custom.png');
assert(path.isAbsolute(settings.favicon)); assert(path.isAbsolute(settings.favicon));