diff --git a/src/discussions/posts/post/Post.jsx b/src/discussions/posts/post/Post.jsx index 870cfedf..07ed12cd 100644 --- a/src/discussions/posts/post/Post.jsx +++ b/src/discussions/posts/post/Post.jsx @@ -4,6 +4,7 @@ import PropTypes from 'prop-types'; import { useDispatch, useSelector } from 'react-redux'; import { useHistory, useLocation } from 'react-router-dom'; +import { getConfig } from '@edx/frontend-platform'; import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; import { Hyperlink, useToggle } from '@edx/paragon'; @@ -35,6 +36,9 @@ function Post({ const { reasonCodesEnabled } = useSelector(selectModerationSettings); const [isDeleting, showDeleteConfirmation, hideDeleteConfirmation] = useToggle(false); const [isClosing, showClosePostModal, hideClosePostModal] = useToggle(false); + + const postURL = new URL(`${getConfig().PUBLIC_PATH}${courseId}/posts/${post.id}`, window.location.origin); + const actionHandlers = { [ContentActions.EDIT_CONTENT]: () => history.push({ ...location, @@ -50,7 +54,7 @@ function Post({ dispatch(updateExistingThread(post.id, { closed: true })); } }, - [ContentActions.COPY_LINK]: () => { navigator.clipboard.writeText(`${window.location.origin}/${courseId}/posts/${post.id}`); }, + [ContentActions.COPY_LINK]: () => { navigator.clipboard.writeText(postURL.href); }, [ContentActions.PIN]: () => dispatch(updateExistingThread(post.id, { pinned: !post.pinned })), [ContentActions.REPORT]: () => dispatch(updateExistingThread(post.id, { flagged: !post.abuseFlagged })), };