Check if a given pathname string contains a possible path traversal attack
const { hasPathTraversal } = require('./index.js');
hasPathTraversal('a/b/c'); // false
hasPathTraversal('/../../../../../../../../../../../etc/passwd%00.jpg'); // true
Just run node test
. Read the test.js doc string to more info.