@@ -23,22 +23,38 @@ export function useDebugMetadata(
2323 offset : number , limit : number ,
2424) {
2525 const fetchWrap = useCallback ( ( fetchFunction : FetchFunction ) => {
26- return fetchDebugMetadata (
27- fetchFunction , execution , path , source , offset , limit ) ;
26+ const url = getMetadataUrl ( execution , path , source , offset , limit ) ;
27+ return fetchDebugMetadata ( fetchFunction , execution , path , source , url ) ;
2828 } , [ execution , path , source , offset , limit ] ) ;
2929 return useFetch < DebugMetadataList > ( fetchWrap ) ;
3030}
3131
3232/**
3333 * For given entry return URL of page with detail.
3434 */
35- export function getMetadataUrl ( entry : DebugEntry ) {
36- const execution = encodeURIComponent ( entry . execution ) ;
37- const path = encodeURIComponent ( entry . fullPath ) ;
38- let result = `/debug?execution=${ execution } &path=${ path } ` ;
39- if ( isDebugFileEntry ( entry ) && entry . source !== undefined ) {
40- result += "&source=" + encodeURIComponent ( entry . source ) ;
35+ export function getMetadataUrl (
36+ execution : string , path : string , source : string | undefined ,
37+ offset : number , limit : number ,
38+ ) {
39+ let result = urlForExecutionAndPath (
40+ "./api/v1/debug/metadata/" , execution , path ) ;
41+ result += "?offset=" + offset + "&limit=" + limit ;
42+ if ( source !== undefined ) {
43+ result += "&source=" + source ;
44+ }
45+ return result ;
46+ }
47+
48+ function urlForExecutionAndPath ( prefix : string , execution : string , path : string ) {
49+ let result = prefix + encodeURI ( execution ) ;
50+ if ( path . length > 0 && path [ 0 ] !== "/" ) {
51+ result += "/" + path
4152 }
53+ // As path can contain encoded sequence, we need to encode
54+ // each fragment again as it gets decoded during the reqeust.
55+ // https://github.com/linkedpipes/etl/issues/976
56+ const encodedPath = path . split ( "/" ) . map ( encodeURI ) . join ( "/" ) ;
57+ result += encodedPath ;
4258 return result ;
4359}
4460
@@ -98,7 +114,8 @@ export function getDownloadUrl(entry: DebugFileMetadata | DebugFileEntry) : {
98114 "name" : name
99115 } ;
100116 }
101- let url = "./api/v1/debug/data/" + entry . execution + entry . fullPath ;
117+ let url = urlForExecutionAndPath (
118+ "./api/v1/debug/data/" , entry . execution , entry . fullPath ) ;
102119 if ( entry . source !== undefined ) {
103120 url += "?source=" + entry . source ;
104121 }
0 commit comments