From 4a02aae19917a8e4b033899cbdbbcdda37a186a9 Mon Sep 17 00:00:00 2001 From: "Matthew.Iannucci" Date: Fri, 3 May 2024 14:57:18 -0400 Subject: [PATCH] More static routing fixes --- viewer/src/components/copy_link.tsx | 6 ++++++ xreds/spastaticfiles.py | 6 +----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/viewer/src/components/copy_link.tsx b/viewer/src/components/copy_link.tsx index da76d02..01338b1 100644 --- a/viewer/src/components/copy_link.tsx +++ b/viewer/src/components/copy_link.tsx @@ -32,6 +32,9 @@ export default function CopyUrl({ let path = origin_path ? window.location.pathname.split(origin_path)[0] : window.location.pathname; + if (path.includes(import.meta.env.VITE_XREDS_BASE_URL)) { + path = path.replace(import.meta.env.VITE_XREDS_BASE_URL, ''); + } if (path.endsWith('/')) { path = path.slice(0, -1); } @@ -59,6 +62,9 @@ export default function CopyUrl({ origin_path, )[0] : window.location.pathname; + if (path.includes(import.meta.env.VITE_XREDS_BASE_URL)) { + path = path.replace(import.meta.env.VITE_XREDS_BASE_URL, ''); + } if (path.endsWith('/')) { path = path.slice(0, -1); } diff --git a/xreds/spastaticfiles.py b/xreds/spastaticfiles.py index adec571..3e868c3 100644 --- a/xreds/spastaticfiles.py +++ b/xreds/spastaticfiles.py @@ -11,11 +11,7 @@ class SPAStaticFiles(StaticFiles): async def get_response(self, path: str, scope): try: - if ( - not path.endswith(".js") - and not path.endswith(".css") - and not path.endswith(".html") - ): + if not '.' in path: raise HTTPException(status_code=404) return await super().get_response(path, scope) except HTTPException as ex: