directory-traversal-js
TypeScript icon, indicating that this package has built-in type declarations

0.0.92 • Public • Published

Directory Traversal JS

Safely upload files and handle paths

Motivation

Directory traversal (also known as file path traversal) is a web security vulnerability that allows an attacker to read arbitrary files on the server.

Install

$ npm install --save directory-traversal-js

Usage

Javascript

var directoryTraversalManager = require('directory-traversal-js');
 
const path = directoryTraversalManager.safeJoin(rootPath, filename)

Typescript

import { safeJoin } from 'directory-traversal-js';
 
const path: string = safeJoin(rootPath, filename);

Explanation

safeJoin throws an error in case a directory traversal has been detected or return the joined path if not.

Package Sidebar

Install

npm i directory-traversal-js

Weekly Downloads

1

Version

0.0.92

License

ISC

Unpacked Size

5.43 kB

Total Files

8

Last publish

Collaborators

  • basicben