Skip to content

Commit 291cd0f

Browse files
committed
Update debug view
Add encoding of path property in URL, #976.
1 parent 64a3b80 commit 291cd0f

File tree

2 files changed

+27
-22
lines changed

2 files changed

+27
-22
lines changed

frontend/client-react/app-service/execution-debug/execution-debug-http.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,12 @@ import {fetchContent, FetchFunction, fetchJson} from "../fetch-service";
55
export async function fetchDebugMetadata(
66
fetchFunction: FetchFunction,
77
execution: string, path: string, source: string | undefined,
8-
offset: number, limit: number
8+
url: string
99
): Promise<DebugMetadataList> {
10-
let url = createMetadataUrl(execution, path);
11-
url += "?offset=" + offset + "&limit=" + limit;
12-
if (source !== undefined) {
13-
url += "&source=" + source;
14-
}
1510
const response = await fetchJson(fetchFunction, url);
1611
return jsonToDebugMetadataList(execution, path, source, response);
1712
}
1813

19-
function createMetadataUrl(execution: string, path: string): string {
20-
if (path.length > 0 && path[0] !== "/") {
21-
path = "/" + path
22-
}
23-
return "./api/v1/debug/metadata/" + execution + path;
24-
}
25-
2614
export async function fetchDebugData(
2715
fetchFunction: FetchFunction,
2816
url: string

frontend/client-react/debug-view/debug-view-service.ts

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)