From 7d0219b11d40ecc981454846e4e7dc2b4be59a22 Mon Sep 17 00:00:00 2001 From: jerbob92 Date: Thu, 6 Oct 2022 21:20:48 +0200 Subject: [PATCH] chore: allow configuration of shortcode base (#2748) --- packages/hoppscotch-app/.env.example | 3 ++- packages/hoppscotch-app/src/components/http/Request.vue | 7 +++++-- .../hoppscotch-app/src/components/profile/Shortcode.vue | 7 +++++-- packages/hoppscotch-app/src/vite-envs.d.ts | 1 + 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/hoppscotch-app/.env.example b/packages/hoppscotch-app/.env.example index c5bd6cbba..673d3505c 100644 --- a/packages/hoppscotch-app/.env.example +++ b/packages/hoppscotch-app/.env.example @@ -14,8 +14,9 @@ VITE_MESSAGING_SENDER_ID=421993993223 VITE_APP_ID=1:421993993223:web:ec0baa8ee8c02ffa1fc6a2 VITE_MEASUREMENT_ID=G-BBJ3R80PJT -# Base URL +# Base URLs VITE_BASE_URL=https://hoppscotch.io +VITE_SHORTCODE_BASE_URL=https://hopp.sh # Backend URLs VITE_BACKEND_GQL_URL=https://api.hoppscotch.io/graphql diff --git a/packages/hoppscotch-app/src/components/http/Request.vue b/packages/hoppscotch-app/src/components/http/Request.vue index 72a82d8db..0f930873b 100644 --- a/packages/hoppscotch-app/src/components/http/Request.vue +++ b/packages/hoppscotch-app/src/components/http/Request.vue @@ -452,17 +452,20 @@ const copyRequest = async () => { } const copyShareLink = (shareLink: string) => { + const link = `${ + import.meta.env.VITE_SHORTCODE_BASE_URL ?? "https://hopp.sh" + }/r${shareLink}` if (navigator.share) { const time = new Date().toLocaleTimeString() const date = new Date().toLocaleDateString() navigator.share({ title: "Hoppscotch", text: `Hoppscotch • Open source API development ecosystem at ${time} on ${date}`, - url: `https://hopp.sh/r${shareLink}`, + url: link, }) } else { copyLinkIcon.value = IconCheck - copyToClipboard(`https://hopp.sh/r${shareLink}`) + copyToClipboard(link) toast.success(`${t("state.copied_to_clipboard")}`) } } diff --git a/packages/hoppscotch-app/src/components/profile/Shortcode.vue b/packages/hoppscotch-app/src/components/profile/Shortcode.vue index a5481fc81..74d6009eb 100644 --- a/packages/hoppscotch-app/src/components/profile/Shortcode.vue +++ b/packages/hoppscotch-app/src/components/profile/Shortcode.vue @@ -18,7 +18,7 @@ const dateStamp = computed(() => shortDateTime(props.shortcode.createdOn)) +const shortcodeBaseURL = + import.meta.env.VITE_SHORTCODE_BASE_URL ?? "https://hopp.sh" + const copyShortcode = (codeID: string) => { - copyToClipboard(`https://hopp.sh/r/${codeID}`) + copyToClipboard(`${shortcodeBaseURL}/r/${codeID}`) toast.success(`${t("state.copied_to_clipboard")}`) copyIconRefs.value = IconCheck } diff --git a/packages/hoppscotch-app/src/vite-envs.d.ts b/packages/hoppscotch-app/src/vite-envs.d.ts index aa2de729e..ae58f12de 100644 --- a/packages/hoppscotch-app/src/vite-envs.d.ts +++ b/packages/hoppscotch-app/src/vite-envs.d.ts @@ -16,6 +16,7 @@ interface ImportMetaEnv { readonly VITE_MEASUREMENT_ID: string readonly VITE_BASE_URL: string + readonly VITE_SHORTCODE_BASE_URL: string readonly VITE_BACKEND_GQL_URL: string readonly VITE_BACKEND_WS_URL: string