# url2

> Node's URL module plus relative pathing

Latest version **1.0.4** (published 2015-03-30) · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2015-03-30 |
| First published | 2012-11-28 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Kris Kowal |
| Maintainers | kriskowal |
| Keywords | url, relative, resolve, parse, format |

## Links

- npm: https://www.npmjs.com/package/url2
- Repository: https://github.com/kriskowal/url2
- Issues: https://github.com/kriskowal/url2/issues
- npm.io page: https://npm.io/package/url2

## Dependencies (1)

- [url](https://npm.io/package/url.md) 0.10.2

## 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.4 (latest) — 2015-03-30
- 2.0.0 (future) — 2014-05-19
- 1.0.3 — 2014-03-21
- 1.0.2 — 2014-03-20
- 1.0.1 — 2014-03-19
- 1.0.0 — 2013-07-20
- 0.0.0 — 2012-11-28

## README

URL2
----

This module builds upon the existing URL module in NodeJS, but adds
`relative(source, target)` which returns the shortest relative path
between any two equally qualified URL’s.  If the paths are not equally
qualified, it returns the target.

In addition, this package augments the URL object definition as returned
by `parse` and consumed by `format`.

-   `pathname` is broken down into
    -   `root`: whether the path is qualified from the root of the
        domain.
    -   `relative`: the relative path, from the root if `pathname` is
        qualified from the domain root.
        -   `directories`: an array of path components
        -   `file`: the name of the file, or null if the URL points to a
            directory, indicated by a final slash.

Additionally, `format` uses the `path` property if it exists, instead of
`pathname` and `search`.

----

Based on my earlier work for [Narwhal][].

[Narwhal]: https://github.com/kriskowal/narwhal-lib/blob/master/lib/narwhal/uri.js

Copyright 2012 Kristopher Michael Kowal. All rights reserved.
MIT License

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