# cwdurl

> use Current Working Directory as URL

Latest version **1.0.0** (published 2023-08-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install cwdurl
pnpm add cwdurl
yarn add cwdurl
bun add cwdurl
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2023-08-21 |
| First published | 2023-08-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 0 |
| Unpacked size | 4.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | LiviaMedeiros |
| Maintainers | liviamedeiros |
| Keywords | nodejs, process, cwd, URL |

## Links

- npm: https://www.npmjs.com/package/cwdurl
- Repository: https://github.com/LiviaMedeiros/cwdurl
- Homepage: https://github.com/LiviaMedeiros/cwdurl#readme
- Issues: https://github.com/LiviaMedeiros/cwdurl/issues
- npm.io page: https://npm.io/package/cwdurl

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2023-08-21

## README

[![MIT License](https://img.shields.io/github/license/LiviaMedeiros/cwdurl)](https://github.com/LiviaMedeiros/cwdurl/blob/HEAD/LICENSE)
[![npm](https://img.shields.io/npm/v/cwdurl.svg)](https://npmjs.com/package/cwdurl)
![npm bundle size](https://img.shields.io/bundlephobia/min/cwdurl)

# `cwdurl`

`cwdurl` allows to work with Current Working Directory as URL

# Installation

```console
$ npm i cwdurl
```

# Usage

```mjs
import * as cwd from 'cwdurl';

// returns CWD with trailing directory separator
const path = cwd.path(); // /path/to/current/working/directory/

// returns CWD as URL instance
const url = cwd.url(); // file:///path/to/current/working/directory/

// returns CWD as urlstring
const href = cwd.href(); // file:///path/to/current/working/directory/

// resolves relative URL against CWD, returns URL instance
const fileInCwd = cwd.resolve('infile.txt'); // file:///path/to/current/working/directory/infile.txt
const fileOutCwd = cwd.resolve('..', 'outfile.txt'); // file:///path/to/current/working/infile.txt
const ignoreCWD = cwd.resolve('file:///home/absfile.txt'); // file:///home/absfile.txt

// changes CWD using URL
cwd.cd('../../other/directory'); // changes to /path/to/current/other/directory/
cwd.cd('file:///tmp'); // changes to /tmp/
```

# Environment variables

If `CWDURL_PERSIST` is set, CWD values will be cached at import time and become immutable. `cwd.url()` will return frozen `URL` instance.

# License

[MIT](https://github.com/LiviaMedeiros/cwdurl/blob/HEAD/LICENSE)

---
_Source: https://npm.io/package/cwdurl · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
