From 361134f9a21ff180da9fd6a5e83a1343056da382 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 20 Mar 2026 10:38:03 -0400 Subject: [PATCH] fix: share url for ap posts, fallback to window.location.href if pid doesnt exist closes #14109 --- public/src/modules/share.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/public/src/modules/share.js b/public/src/modules/share.js index e9e6c27489..94478d30cf 100644 --- a/public/src/modules/share.js +++ b/public/src/modules/share.js @@ -17,7 +17,7 @@ define('share', ['hooks'], function (hooks) { $('#content').off('shown.bs.dropdown', '.share-dropdown').on('shown.bs.dropdown', '.share-dropdown', function () { 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 setTimeout(function () { @@ -77,9 +77,10 @@ define('share', ['hooks'], function (hooks) { } function getPostUrl(clickedElement) { - const pid = parseInt(clickedElement.parents('[data-pid]').attr('data-pid'), 10); - const path = '/post' + (pid ? '/' + (pid) : ''); - return baseUrl + config.relative_path + path; + const pid = clickedElement.parents('[data-pid]').attr('data-pid'); + return pid ? + `${baseUrl + config.relative_path}/post/${pid}` : + window.location.href; } return share;