17109: Handles keep-web's inline wildcard urls correctly.
[arvados-workbench2.git] / src / views-components / context-menu / actions / collection-file-viewer-action.tsx
index dfc9d14acd7e5552e5daa23e9256b04ab819f764..aba355346bdbdf5fa9398a08d3faa53cd963818c 100644 (file)
@@ -7,6 +7,7 @@ import { RootState } from "../../../store/store";
 import { FileViewerAction } from '~/views-components/context-menu/actions/file-viewer-action';
 import { getNodeValue } from "~/models/tree";
 import { ContextMenuKind } from '~/views-components/context-menu/context-menu';
+import { getInlineFileUrl, sanitizeToken } from "./helpers";
 
 const mapStateToProps = (state: RootState) => {
     const { resource } = state.contextMenu;
@@ -16,8 +17,12 @@ const mapStateToProps = (state: RootState) => {
         resource.menuKind === ContextMenuKind.READONLY_COLLECTION_FILES_ITEM)) {
         const file = getNodeValue(resource.uuid)(state.collectionPanelFiles);
         if (file) {
+            const fileUrl = sanitizeToken(getInlineFileUrl(
+                file.url,
+                state.auth.config.keepWebServiceUrl,
+                state.auth.config.keepWebInlineServiceUrl), true);
             return {
-                href: file.url.replace(state.auth.config.keepWebServiceUrl, state.auth.config.keepWebInlineServiceUrl),
+                href: fileUrl,
                 kind: 'file',
                 currentCollectionUuid
             };