From 8bd47641839ba1e6cd19e30b87184763f28a009e Mon Sep 17 00:00:00 2001 From: Marshall Polaris Date: Tue, 30 Aug 2022 01:49:29 -0700 Subject: [PATCH] Make copy link component copy better URL --- web/components/feed/copy-link-date-time.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web/components/feed/copy-link-date-time.tsx b/web/components/feed/copy-link-date-time.tsx index c4e69655..d4401b8c 100644 --- a/web/components/feed/copy-link-date-time.tsx +++ b/web/components/feed/copy-link-date-time.tsx @@ -1,5 +1,4 @@ import React, { useState } from 'react' -import { ENV_CONFIG } from 'common/envs/constants' import { copyToClipboard } from 'web/lib/util/copy' import { DateTimeTooltip } from 'web/components/datetime-tooltip' import Link from 'next/link' @@ -21,9 +20,10 @@ export function CopyLinkDateTimeComponent(props: { event: React.MouseEvent ) { event.preventDefault() - const elementLocation = `https://${ENV_CONFIG.domain}/${prefix}/${slug}#${elementId}` - - copyToClipboard(elementLocation) + const commentUrl = new URL(window.location.href) + commentUrl.pathname = `/${prefix}/${slug}` + commentUrl.hash = elementId + copyToClipboard(commentUrl.toString()) setShowToast(true) setTimeout(() => setShowToast(false), 2000) }