Skip to content

Commit ff8a508

Browse files
authored
Merge pull request #160 from contentstack/fix/dev2
sanitizepath
2 parents ddc113d + 359ee9a commit ff8a508

File tree

3 files changed

+8
-71
lines changed

3 files changed

+8
-71
lines changed

package-lock.json

Lines changed: 1 addition & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,19 @@
88
"@contentstack/cli-command": "^1.3.2",
99
"@contentstack/cli-utilities": "^1.8.0",
1010
"@contentstack/types-generator": "^2.0.3",
11-
"async": "^3.2.6",
12-
"dotenv": "^16.4.7",
13-
"fancy-test": "^3.0.16",
14-
"graphql": "^16.8.1",
15-
"lodash": "^4.17.21",
16-
"prettier": "^3.4.2",
17-
"tslib": "^2.8.1"
11+
"dotenv": "^16.4.7"
1812
},
1913
"devDependencies": {
2014
"@oclif/plugin-help": "^3.3.1",
2115
"@oclif/test": "^4.0.9",
22-
"@types/async": "^3.2.24",
23-
"@types/chai": "^4.3.20",
2416
"@types/jest": "^26.0.24",
25-
"@types/lodash": "^4.17.14",
26-
"@types/mocha": "^10.0.10",
2717
"@types/node": "^10.17.60",
28-
"chai": "^5.1.2",
2918
"eslint": "^5.16.0",
3019
"eslint-config-oclif": "^3.1.2",
3120
"eslint-config-oclif-typescript": "^0.2.0",
32-
"globby": "^10.0.2",
3321
"jest": "^26.6.3",
34-
"mocha": "^10.7.3",
3522
"oclif": "^3.17.2",
3623
"ts-jest": "^26.5.6",
37-
"ts-node": "^10.9.2",
3824
"typescript": "^4.9.5"
3925
},
4026
"engines": {
@@ -63,7 +49,7 @@
6349
"repository": "Contentstack-Solutions/contentstack-cli-tsgen",
6450
"scripts": {
6551
"postpack": "rm -f oclif.manifest.json",
66-
"posttest": "eslint . --ext .ts --config .eslintrc",
52+
"posttest": "eslint . --ext .ts --config .eslintrc --fix",
6753
"prepack": "rm -rf lib && tsc -b && oclif manifest && oclif readme",
6854
"test": "jest --testPathPattern=tests",
6955
"version": "oclif readme && git add README.md",

src/lib/helper.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
export const sanitizePath = (str: string) => str?.replace(/^(\.\.(\/|\\|$))+/, '');
1+
export const sanitizePath = (str: string) => {
2+
return str
3+
?.replace(/[\/\\]+/g, "/") // Replace multiple slashes/backslashes with a single '/'
4+
.replace(/(\.\.(\/|\\|$))+/g, ""); // Remove directory traversal (../ or ..\)
5+
}

0 commit comments

Comments
 (0)