How to use resolve-path - 1 common examples

To help you get started, we’ve selected a few resolve-path examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github patternplate / patternplate / source / application / routes / patternStatic.js View on Github external
if ( [ 'HEAD', 'GET' ].indexOf( this.method ) === -1 ) {
		return;
	}

	let path = this.captures[0];
	path = path[ 0 ] === '/' ? path.slice( 1 ) : path;

	try {
		path = decodeURIComponent( path )
	} catch ( err ) {
		application.log.error( 'Could not decode path' );
		application.log.debug( err );
		this.throw( 'failed to decode', 400 );
	}

	path = resolvePath( root, path );

	if ( basename( path )[ 0 ] === '.' ) {
		return;
	}

	let stats;

	try {
		stats = await stat( path );
		if ( stats.isDirectory() ) {
			return;
		}
	} catch ( err ) {
		if ( notfound.indexOf( err.code ) > -1 ) {
			return;
		}

resolve-path

Resolve a relative path against a root path with validation

MIT
Latest version published 6 years ago

Package Health Score

66 / 100
Full package analysis

Popular resolve-path functions