We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1f44fcc commit fd3316eCopy full SHA for fd3316e
src/lib/helper.ts
@@ -1 +1,5 @@
1
-export const sanitizePath = (str: string) => str?.replace(/^(\.\.(\/|\\|$))+/, '');
+export const sanitizePath = (str: string) =>
2
+ str
3
+ ?.replace(/^([\/\\])+/, "./") // Normalize leading slashes/backslashes to './'
4
+ .replace(/[\/\\]+/g, "/") // Replace multiple slashes/backslashes with a single '/'
5
+ .replace(/(\.\.(\/|\\|$))+/g, ""); // Remove directory traversal (../ or ..\)
0 commit comments