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

url-or-path

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

url-or-path

Convert between file URL and path.

  • 2.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
61K
decreased by-15.97%
Maintainers
1
Weekly downloads
 
Created
Source

url-or-path

Build Status Coverage Npm Version MIT License

Convert between file URL and path.

Install

yarn add url-or-path

Usage

import {toUrl, toPath} from 'url-or-path'

console.log(toUrl(urlOrPath))
//=> URL {/* ... */}

console.log(toPath(urlOrPath))
//=> 'path/to/file'

API

toUrl(urlOrPath)(alias toURL)

Type: string | URL

Returns a URL object of given URL or path string.

toPath(urlOrPath)

Type: string | URL

Returns path string of given URL or path string.

toDirectory(urlOrPath)

Type: string | URL

Same as toUrl, but the result URL always ends with /.

isUrl(object)

Check if object is a URL instance of file:// string.

isUrlInstance(object)

Check if object is a URL instance.

isUrlString(object)

Check if object is a file:// string

FAQs

Package last updated on 11 Feb 2022

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