Skip to content

Commit 361134f

Browse files
committed
fix: share url for ap posts, fallback to window.location.href if pid doesnt exist
closes #14109
1 parent c480df9 commit 361134f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

public/src/modules/share.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ define('share', ['hooks'], function (hooks) {
1717

1818
$('#content').off('shown.bs.dropdown', '.share-dropdown').on('shown.bs.dropdown', '.share-dropdown', function () {
1919
const postLink = $(this).find('.post-link');
20-
postLink.val(baseUrl + getPostUrl($(this)));
20+
postLink.val(getPostUrl($(this)));
2121

2222
// without the setTimeout can't select the text in the input
2323
setTimeout(function () {
@@ -77,9 +77,10 @@ define('share', ['hooks'], function (hooks) {
7777
}
7878

7979
function getPostUrl(clickedElement) {
80-
const pid = parseInt(clickedElement.parents('[data-pid]').attr('data-pid'), 10);
81-
const path = '/post' + (pid ? '/' + (pid) : '');
82-
return baseUrl + config.relative_path + path;
80+
const pid = clickedElement.parents('[data-pid]').attr('data-pid');
81+
return pid ?
82+
`${baseUrl + config.relative_path}/post/${pid}` :
83+
window.location.href;
8384
}
8485

8586
return share;

0 commit comments

Comments
 (0)