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 - npm Package Compare versions

Comparing version 2.3.0 to 2.3.1

15

index.js
import {fileURLToPath, pathToFileURL} from 'node:url'
/** @typedef {URL | string} UrlOrPath */
const URL_STRING_PREFIX = 'file:'
/**
@typedef {typeof URL_STRING_PREFIX} UrlStringPrefix
@typedef {`${UrlStringPrefix}${string}`} UrlString
@typedef {URL | UrlString} UrlOrUrlString
@typedef {URL | string} UrlOrPath
*/
/** @type {(value: unknown) => value is URL} */
const isUrlInstance = (value) => value instanceof URL
/** @type {(value: unknown) => value is string} */
/** @type {(value: unknown) => value is UrlString} */
const isUrlString = (value) =>
typeof value === 'string' && value.startsWith('file://')
/** @type {(urlOrPath: unknown) => urlOrPath is UrlOrPath} */
typeof value === 'string' && value.startsWith(URL_STRING_PREFIX)
/** @type {(urlOrPath: unknown) => urlOrPath is UrlOrUrlString} */
const isUrl = (urlOrPath) => isUrlInstance(urlOrPath) || isUrlString(urlOrPath)

@@ -12,0 +19,0 @@

{
"name": "url-or-path",
"version": "2.3.0",
"version": "2.3.1",
"description": "Convert between file URL and path.",

@@ -26,5 +26,5 @@ "homepage": "https://github.com/fisker/url-or-path#readme",

"scripts": {
"build": "run-p build:*",
"build:types": "tsc",
"clean": "run-p clean:*",
"build": "yarn clean && run-p \"build:*\"",
"build:types": "tsc --emitDeclarationOnly --noEmit false",
"clean": "run-p \"clean:*\"",
"clean:dist": "del-cli index.d.ts index.d.ts.map",

@@ -44,5 +44,7 @@ "dist": "run-p dist:*",

"prepare": "husky install",
"release": "run-s format clean build test dist",
"test": "ava",
"test-coverage": "c8 ava"
"release": "run-s format build test dist",
"test": "run-p \"test:*\"",
"test-coverage": "c8 yarn test",
"test:js": "ava",
"test:types": "yarn build && tsd"
},

@@ -75,2 +77,3 @@ "ava": {

"sort-package-json": "2.6.0",
"tsd": "0.29.0",
"typescript": "5.2.2"

@@ -77,0 +80,0 @@ },

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