From ac595e338969f0b76def9f2251655eac85343ca7 Mon Sep 17 00:00:00 2001 From: netpro2k <netpro2k@gmail.com> Date: Fri, 2 Nov 2018 16:38:07 -0700 Subject: [PATCH] Always resolve an absolute url for sharing --- src/utils/phoenix-utils.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/utils/phoenix-utils.js b/src/utils/phoenix-utils.js index 5d5307db8..7cbca9fa0 100644 --- a/src/utils/phoenix-utils.js +++ b/src/utils/phoenix-utils.js @@ -36,9 +36,13 @@ export function connectToReticulum(debug = false) { return socket; } -export function getReticulumFetchUrl(path) { +const resolverLink = document.createElement("a"); +export function getReticulumFetchUrl(path, absolute = false) { if (process.env.RETICULUM_SERVER) { return `https://${process.env.RETICULUM_SERVER}${path}`; + } else if (absolute) { + resolverLink.href = path; + return resolverLink.href; } else { return path; } @@ -46,5 +50,5 @@ export function getReticulumFetchUrl(path) { export function getLandingPageForPhoto(photoUrl) { const parsedUrl = new URL(photoUrl); - return getReticulumFetchUrl(parsedUrl.pathname.replace(".png", ".html") + parsedUrl.search); + return getReticulumFetchUrl(parsedUrl.pathname.replace(".png", ".html") + parsedUrl.search, true); } -- GitLab