Skip to content

Node.js based forum software built for the modern web

closes #3220

barisusaklied72bacb1f67
diff --git a/app.js b/app.js
index 78f9e01188..97f1fe23e1 100644
--- a/app.js
+++ b/app.js
@@ -118,6 +118,7 @@ function start() {
// Parse out the relative_url and other goodies from the configured URL
var urlObject = url.parse(nconf.get('url'));
var relativePath = urlObject.pathname !== '/' ? urlObject.pathname : '';
+ nconf.set('base_url', urlObject.protocol + '//' + urlObject.host);
nconf.set('use_port', !!urlObject.port);
nconf.set('relative_path', relativePath);
nconf.set('port', urlObject.port || nconf.get('port') || nconf.get('PORT') || 4567);
diff --git a/src/user/digest.js b/src/user/digest.js
index d1e9be76e0..056eebd508 100644
--- a/src/user/digest.js
+++ b/src/user/digest.js
@@ -39,14 +39,9 @@ var async = require('async'),
// Fix relative paths in topic data
data.topics.topics = data.topics.topics.map(function(topicObj) {
- if (topicObj.hasOwnProperty('teaser') && topicObj.teaser !== undefined) {
- if (utils.isRelativeUrl(topicObj.teaser.user.picture)) {
- topicObj.teaser.user.picture = nconf.get('url') + topicObj.teaser.user.picture;
- }
- } else {
- if (utils.isRelativeUrl(topicObj.user.picture)) {
- topicObj.user.picture = nconf.get('url') + topicObj.user.picture;
- }
+ var user = topicObj.hasOwnProperty('teaser') && topicObj.teaser !== undefined ? topicObj.teaser.user : topicObj.user;
+ if (user && user.picture && utils.isRelativeUrl(user.picture)) {
+ user.picture = nconf.get('base_url') + user.picture;
}
return topicObj;