|
|
@ -17,21 +17,23 @@ module.exports = function(Meta) {
|
|
|
|
|
|
|
|
|
|
|
|
Meta.title.build = function (urlFragment, language, locals, callback) {
|
|
|
|
Meta.title.build = function (urlFragment, language, locals, callback) {
|
|
|
|
var uri = '';
|
|
|
|
var uri = '';
|
|
|
|
|
|
|
|
var fallbackTitle = Meta.config.browserTitle || Meta.config.title || 'NodeBB';
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
uri = decodeURIComponent(urlFragment);
|
|
|
|
uri = decodeURIComponent(urlFragment);
|
|
|
|
} catch(e) {
|
|
|
|
} catch(e) {
|
|
|
|
winston.error('Invalid url fragment : ' + urlFragment, e.stack);
|
|
|
|
winston.error('Invalid url fragment : ' + urlFragment, e.stack);
|
|
|
|
return callback(null, Meta.config.browserTitle || 'NodeBB');
|
|
|
|
return callback(null, fallbackTitle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Meta.title.parseFragment(uri, language, locals, function(err, title) {
|
|
|
|
Meta.title.parseFragment(uri, language, locals, function(err, title) {
|
|
|
|
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
|
title = Meta.config.browserTitle || 'NodeBB';
|
|
|
|
title = fallbackTitle;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (title) {
|
|
|
|
if (title) {
|
|
|
|
title = validator.escape(title);
|
|
|
|
title = validator.escape(title);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
title = (title ? title + ' | ' : '') + (Meta.config.browserTitle || 'NodeBB');
|
|
|
|
title = (title ? title + ' | ' : '') + fallbackTitle;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
callback(null, title);
|
|
|
|
callback(null, title);
|
|
|
|