File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,14 @@ export const collectionJsonToJson = (theData: any) => {
7878 return typeof theData . collection . total === "undefined" ? ret [ 0 ] : ret ;
7979} ;
8080
81+ export const sanitizeAPIRootURL = ( API_ROOT : string ) => {
82+ if ( API_ROOT . length >= 1 && API_ROOT [ API_ROOT . length - 1 ] === "/" ) {
83+ return API_ROOT . slice ( 0 , API_ROOT . length - 1 ) ;
84+ }
85+
86+ return API_ROOT ;
87+ } ;
88+
8189const callApi = async < T > (
8290 endpoint : string ,
8391 {
@@ -96,10 +104,8 @@ const callApi = async <T>(
96104
97105 const default_api_root = window . location . origin ;
98106
99- let API_ROOT = paramsAPIRoot || CONFIG_API_ROOT || default_api_root ;
100- if ( API_ROOT . length >= 1 && API_ROOT [ API_ROOT . length - 1 ] === "/" ) {
101- API_ROOT = API_ROOT . slice ( 0 , API_ROOT . length - 1 ) ;
102- }
107+ const theAPIRootURL = paramsAPIRoot || CONFIG_API_ROOT || default_api_root ;
108+ const API_ROOT = sanitizeAPIRootURL ( theAPIRootURL ) ;
103109
104110 let theEndpoint = endpoint ;
105111 if ( ! theEndpoint . includes ( API_ROOT ) ) {
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import {
1515 useReducer ,
1616} from "react-reducer-utils" ;
1717import { useLocation , useSearchParams } from "react-router-dom" ;
18+ import { sanitizeAPIRootURL } from "../../api/api.ts" ;
1819import type { Lonk , LonkMessageData } from "../../api/lonk/types.ts" ;
1920import type { PACSqueryCore } from "../../api/pfdcm/index.ts" ;
2021import * as DoPacs from "../../reducers/pacs" ;
@@ -203,7 +204,8 @@ export default () => {
203204 . map ( ( each ) => each . SeriesInstanceUID )
204205 . join ( "," ) ;
205206
206- const url = `${ config . API_ROOT } /pacs/sse/?pacs_name=${ service } &series_uids=${ series_uids } ` ;
207+ const apiRootURL = sanitizeAPIRootURL ( config . API_ROOT ) ;
208+ const url = `${ apiRootURL } /pacs/sse/?pacs_name=${ service } &series_uids=${ series_uids } ` ;
207209 const eventSource = new EventSource ( url ) ;
208210 console . info ( "PacsApp.eventSource: new eventSource" ) ;
209211
You can’t perform that action at this time.
0 commit comments