File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
packages/contentstack-utilities/src Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -53,12 +53,16 @@ export const validatePath = (input: string) => {
5353// To escape special characters in a string
5454export const escapeRegExp = ( str : string ) => str ?. replace ( / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g, '\\$&' ) ;
5555
56- const sanitizePathRegex = ( str :string ) => str ?. replace ( / ^ ( \. \. ( \/ | \\ | $ ) ) + / , '' ) . replace ( / ^ ( \. ( \/ | \\ | $ ) ) + / , '/' )
56+ const sanitizePathRegex = ( str : string ) =>
57+ str
58+ ?. replace ( / \\ / g, '/' ) // Convert Windows-style backslashes to forward slashes
59+ . replace ( / \/ + / g, '/' ) // Collapse multiple slashes into one
60+ . replace ( / (?: ^ | \/ ) \. + ( \/ | $ ) / g, '/' ) ; // Remove any `.` or `..` path segments
5761
5862// To remove the relative path
5963export const sanitizePath = ( str : string ) => {
6064 const decodedStr = decodeURIComponent ( str ) ;
61- return normalize ( sanitizePathRegex ( decodedStr ) )
65+ return normalize ( sanitizePathRegex ( decodedStr ) ) ;
6266} ;
6367
6468// To validate the UIDs of assets
You can’t perform that action at this time.
0 commit comments