Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

resolve-pathname

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

resolve-pathname

Resolve URL pathnames using JavaScript

  • 2.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.3M
decreased by-14.65%
Maintainers
1
Weekly downloads
 
Created

What is resolve-pathname?

The resolve-pathname npm package is a utility for resolving target URLs or file paths relative to a base URL or file path. It is particularly useful in web development for handling relative paths and ensuring that URLs are correctly formed.

What are resolve-pathname's main functionalities?

Resolve Relative Path

This feature allows you to resolve a relative path against a base path. In this example, 'bar' is resolved relative to '/foo', resulting in '/foo/bar'.

const resolvePathname = require('resolve-pathname');
const resolvedPath = resolvePathname('bar', '/foo');
console.log(resolvedPath); // Output: '/foo/bar'

Resolve Path with Parent Directory

This feature handles paths that navigate up the directory tree. Here, '../bar' is resolved relative to '/foo/baz', resulting in '/bar'.

const resolvePathname = require('resolve-pathname');
const resolvedPath = resolvePathname('../bar', '/foo/baz');
console.log(resolvedPath); // Output: '/bar'

Resolve Absolute Path

This feature ensures that absolute paths are correctly resolved. In this case, '/bar' remains '/bar' regardless of the base path '/foo'.

const resolvePathname = require('resolve-pathname');
const resolvedPath = resolvePathname('/bar', '/foo');
console.log(resolvedPath); // Output: '/bar'

Other packages similar to resolve-pathname

FAQs

Package last updated on 23 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc