Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions java/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
Expand All @@ -22,6 +23,7 @@
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
Expand Down
28 changes: 26 additions & 2 deletions lib/views/logo.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,34 @@
const config = require('../config')
const path = require('path')
const fs = require('fs')

function get (req, res) {
// Prefer logoFilename (full absolute path) if available
let logoFilename = config.get('logoFilename')

if (logoFilename && fs.existsSync(logoFilename)) {
// Use the absolute path directly
return res.sendFile(logoFilename)
}

// Fall back to instanceLogo (relative path)
let instanceLogo = config.get('instanceLogo')
if (!instanceLogo) {
return res.status(404).send('Logo not found')
}

// Remove leading slash if present, as res.sendFile with root option expects relative path
let relativePath = instanceLogo.startsWith('/') ? instanceLogo.substring(1) : instanceLogo
var dir = path.resolve(__dirname, '../../uploads')
let logoFilename = config.get('instanceLogo')
res.sendFile(logoFilename, { root: dir })
let fullPath = path.join(dir, relativePath)

// Check if file exists
if (!fs.existsSync(fullPath)) {
return res.status(404).send('Logo not found')
}

// Send the file using root option
res.sendFile(relativePath, { root: dir })
}

module.exports = get
Loading