Latest Threat ResearchGlassWorm Loader Hits Open VSX via Developer Account Compromise.Details
Socket
Book a DemoInstallSign in
Socket

url-or-path

Package Overview
Dependencies
Maintainers
1
Versions
17
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.

Source
npmnpm
Version
2.6.0
Version published
Weekly downloads
104K
20.64%
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.

toAbsolute(urlOrPath)

Type: string | URL

Returns absolute path string of given URL or path string.

toDirectory(urlOrPath)

Type: string | URL

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

isUrl(value)(alias isURL)

Check if value is a URL instance or a string starts with file://.

isUrlInstance(value)(alias isURLInstance)

Check if value is a URL instance.

isUrlString(value)(alias isURLString)

Check if value is a string starts with file://.

FAQs

Package last updated on 28 Apr 2025

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