@@ -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 ( / ~ f s ~ / 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 || "" , / ~ f s ~ / g) ;
7875
7976 return Uri . parse (
8077 `${ readOnly ? `${ ContentSourceType . SASServer } ReadOnly` : ContentSourceType . SASServer } :/${ pathToUse } ?id=${ getResourceIdFromItem ( item ) } ` ,
0 commit comments