Skip to content

Commit 2a15b08

Browse files
committed
feat(ContentNavigator): added process path logic
Signed-off-by: Kishan Patel <[email protected]>
1 parent 68edf9f commit 2a15b08

File tree

2 files changed

+16
-22
lines changed

2 files changed

+16
-22
lines changed

client/src/connection/rest/RestContentAdapter.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,7 @@ class RestContentAdapter implements ContentAdapter {
236236
}
237237
}
238238
const filePathParts = [];
239-
let currentContentItem: Pick<
240-
ContentItem,
241-
"parentFolderUri" | "name" | "id"
242-
> = item;
239+
let currentContentItem: ContentItem = item;
243240
filePathParts.push(currentContentItem.name);
244241

245242
do {

client/src/connection/rest/util.ts

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,10 @@ export const getResourceIdFromItem = (item: ContentItem): string | null => {
3838
return getLink(item.links, "GET", "self")?.uri || null;
3939
};
4040

41-
export const getSasContentUri = (
42-
item: ContentItem,
43-
readOnly?: boolean,
44-
fullPath?: string,
45-
): Uri => {
46-
let pathToUse = fullPath || item.name || "";
41+
const processPath = (path: string, replacement?: RegExp): string => {
42+
let pathToUse = path;
43+
44+
pathToUse = replacement ? pathToUse.replace(replacement, "/") : pathToUse;
4745

4846
// Remove leading slash if present since we'll add one in the URI construction
4947
if (pathToUse.startsWith("/")) {
@@ -53,6 +51,16 @@ export const getSasContentUri = (
5351
// URL encode special characters
5452
pathToUse = pathToUse.replace(/#/g, "%23").replace(/\?/g, "%3F");
5553

54+
return pathToUse;
55+
};
56+
57+
export const getSasContentUri = (
58+
item: ContentItem,
59+
readOnly?: boolean,
60+
fullPath?: string,
61+
): Uri => {
62+
const pathToUse = processPath(fullPath || item.name || "");
63+
5664
return Uri.parse(
5765
`${readOnly ? `${ContentSourceType.SASContent}ReadOnly` : ContentSourceType.SASContent}:/${pathToUse}?id=${getResourceIdFromItem(item)}`,
5866
);
@@ -63,18 +71,7 @@ export const getSasServerUri = (
6371
readOnly?: boolean,
6472
fullPath?: string,
6573
): Uri => {
66-
let pathToUse = fullPath || item.name || "";
67-
68-
// Decode SAS server path encoding (~fs~ represents /)
69-
pathToUse = pathToUse.replace(/~fs~/g, "/");
70-
71-
// Remove leading slash if present since we'll add one in the URI construction
72-
if (pathToUse.startsWith("/")) {
73-
pathToUse = pathToUse.substring(1);
74-
}
75-
76-
// URL encode special characters
77-
pathToUse = pathToUse.replace(/#/g, "%23").replace(/\?/g, "%3F");
74+
const pathToUse = processPath(fullPath || item.name || "", /~fs~/g);
7875

7976
return Uri.parse(
8077
`${readOnly ? `${ContentSourceType.SASServer}ReadOnly` : ContentSourceType.SASServer}:/${pathToUse}?id=${getResourceIdFromItem(item)}`,

0 commit comments

Comments
 (0)