mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-07 15:20:04 +01:00
stripped double relative path from og urls, #6442
This commit is contained in:
@@ -124,13 +124,13 @@ Tags.parse = function (req, data, meta, link, callback) {
|
||||
|
||||
addIfNotExists(meta, 'property', 'og:title', Meta.config.title || 'NodeBB');
|
||||
|
||||
var ogUrl = nconf.get('url') + (req.originalUrl !== '/' ? req.originalUrl : '');
|
||||
var ogUrl = nconf.get('url') + (req.originalUrl !== '/' ? stripRelativePath(req.originalUrl) : '');
|
||||
addIfNotExists(meta, 'property', 'og:url', ogUrl);
|
||||
|
||||
addIfNotExists(meta, 'name', 'description', Meta.config.description);
|
||||
addIfNotExists(meta, 'property', 'og:description', Meta.config.description);
|
||||
|
||||
var ogImage = Meta.config['og:image'] || Meta.config['brand:logo'] || '';
|
||||
var ogImage = stripRelativePath(Meta.config['og:image'] || Meta.config['brand:logo'] || '');
|
||||
if (ogImage && !ogImage.startsWith('http')) {
|
||||
ogImage = nconf.get('url') + ogImage;
|
||||
}
|
||||
@@ -165,3 +165,11 @@ function addIfNotExists(meta, keyName, tagName, value) {
|
||||
meta.push(data);
|
||||
}
|
||||
}
|
||||
|
||||
function stripRelativePath(url) {
|
||||
if (url.startsWith(nconf.get('relative_path'))) {
|
||||
return url.slice(nconf.get('relative_path').length);
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user