Registry / testing / is-local-path

is-local-path

JSON →
library0.1.6jsnpmunverified

This package, `is-local-path`, provides a utility function to determine if a given string represents a local file system path rather than a remote URL (like HTTP/HTTPS) or a data URI. It achieves this by checking for common remote path prefixes and data URI schemes. The current stable version is `0.1.6`, which was last updated approximately seven years ago (around 2017), indicating that the project is no longer actively maintained. Due to its age and lack of updates, it primarily supports CommonJS environments, and its path detection logic may not fully account for all modern path conventions, browser-specific path structures, or exotic URL schemes introduced since its last release. It serves as a straightforward, lightweight checker for basic local path identification, distinguishing common local paths (e.g., `/a/b`, `./c`, `../d`) from network or data paths.

npm install is-local-path
INSTALL
IMPORT
SIG · IS-LOCAL-PATH
I
is-local-path
testingjavascriptv0.1.6
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

isLocalPath
✓ const isLocalPath = require('is-local-path');
This package is primarily a CommonJS module, suitable for Node.js environments. The function is exported as the default.
isLocalPath
✓ import isLocalPath from 'is-local-path';
✗ import { isLocalPath } from 'is-local-path';
While this module does not officially support ESM, bundlers or Node.js's CJS interoperability (when `type: module` is not set) might allow a default import. Named imports (`{ isLocalPath }`) will likely fail as it's not explicitly exported that way.

This quickstart demonstrates how to import and use the `isLocalPath` function to test various path strings, differentiating between local file system paths and non-local URI schemes.

const isLocalPath = require('is-local-path'); console.log(isLocalPath('/path/to/file.ext')); // true console.log(isLocalPath('/path/to/directory')); // true console.log(isLocalPath('./relative/path')); // true console.log(isLocalPath('../relative/path')); // true console.log(isLocalPath('http://host.com/path/to/file.ext')); // false console.log(isLocalPath('data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D')); // false
Debug
Known issues
gotchaThe `is-local-path` package is effectively abandoned, with its last update occurring approximately seven years ago (version 0.1.6). This means it receives no further maintenance, bug fixes, or security updates. Users should be aware of potential vulnerabilities or unhandled edge cases with modern path formats.
fix
Consider using more actively maintained alternatives or implementing custom path validation logic if strict security or up-to-date path parsing is required.
affects: <=0.1.6
gotchaThis package was developed for CommonJS environments and does not officially support ES Modules (ESM). Direct named imports (`import { isLocalPath } from 'is-local-path'`) will likely result in an undefined export or runtime error without transpilation or specific Node.js CJS-ESM interop settings.
fix
For ESM projects, use `import isLocalPath from 'is-local-path';` and ensure your bundler or Node.js environment is configured to handle CommonJS module interoperability. The `require()` syntax remains the most reliable for Node.js CJS projects.
affects: <=0.1.6
gotchaThe path detection logic in `is-local-path` is simple and might not cover all modern or nuanced path definitions, especially those used in browser environments (e.g., `blob:` URLs, service worker caches, or certain `file://` URL interpretations by browsers) or specific OS-level path quirks. It primarily checks for common remote prefixes.
fix
Thoroughly test with your specific path types. For complex scenarios, consider using `new URL()` to robustly parse and validate paths or implementing more comprehensive regex patterns.
affects: <=0.1.6
Errors
Common errors & fixes
TypeError: isLocalPath is not a function
Attempting to use `import { isLocalPath } from 'is-local-path';` in an ES Module context where the package only provides a default export.
fix
Change your import statement to `import isLocalPath from 'is-local-path';` if using ESM, or `const isLocalPath = require('is-local-path');` for CommonJS.
ReferenceError: require is not defined
Attempting to use `require('is-local-path')` in an ES Module file (`.mjs` or `type: module` in `package.json`) without appropriate transpilation or Node.js loader configuration.
fix
If working in an ESM environment, use `import isLocalPath from 'is-local-path';`. If you intend to use CommonJS, ensure your file is `.js` and `type` is not `module` in `package.json`.
Upgrade
Version history
0.1.6latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
is-local-path — npm install is-local-path · libregistry