fix: share url for ap posts, fallback to window.location.href if pid doesnt exist

closes #14109
This commit is contained in:
Barış Soner Uşaklı
2026-03-20 10:38:03 -04:00
parent c480df9e9c
commit 361134f9a2

View File

@@ -17,7 +17,7 @@ define('share', ['hooks'], function (hooks) {
$('#content').off('shown.bs.dropdown', '.share-dropdown').on('shown.bs.dropdown', '.share-dropdown', function () { $('#content').off('shown.bs.dropdown', '.share-dropdown').on('shown.bs.dropdown', '.share-dropdown', function () {
const postLink = $(this).find('.post-link'); const postLink = $(this).find('.post-link');
postLink.val(baseUrl + getPostUrl($(this))); postLink.val(getPostUrl($(this)));
// without the setTimeout can't select the text in the input // without the setTimeout can't select the text in the input
setTimeout(function () { setTimeout(function () {
@@ -77,9 +77,10 @@ define('share', ['hooks'], function (hooks) {
} }
function getPostUrl(clickedElement) { function getPostUrl(clickedElement) {
const pid = parseInt(clickedElement.parents('[data-pid]').attr('data-pid'), 10); const pid = clickedElement.parents('[data-pid]').attr('data-pid');
const path = '/post' + (pid ? '/' + (pid) : ''); return pid ?
return baseUrl + config.relative_path + path; `${baseUrl + config.relative_path}/post/${pid}` :
window.location.href;
} }
return share; return share;