# get-relative-path

> Return the relative path from one path to another

Latest version **1.0.2** (published 2019-06-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install get-relative-path
pnpm add get-relative-path
yarn add get-relative-path
bun add get-relative-path
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2019-06-22 |
| First published | 2019-06-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Sam Lanning |
| Maintainers | samlanning |
| Keywords | relative, path |

## Links

- npm: https://www.npmjs.com/package/get-relative-path
- Repository: https://github.com/samlanning/ts-util/tree/master/get-relative-path
- npm.io page: https://npm.io/package/get-relative-path

## 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.2 (latest) — 2019-06-22
- 1.0.1 — 2019-06-22
- 1.0.0 — 2019-06-22
- 0.0.1 — 2019-06-21

## README

# get-relative-path

[![](https://img.shields.io/npm/v/get-relative-path.svg)](https://www.npmjs.com/package/get-relative-path)

Work out what the relative path to get from `from` to `to` is.
i.e. Starting at `from`, what path would lead us to `to`.

Similar to Node.js's [path.relative()](https://nodejs.org/api/path.html#path_path_relative_from_to)
but works outside the context of a filesystem, and assumes
all paths are POSIX-style.
So this also works for URL pathnames.

```
npm install get-relative-path
```

```js
const getRelativePath = require('get-relative-path');

console.log(getRelativePath('/data/orandea/test/aaa/', '/data/orandea/impl/bbb'));
// ../../impl/bbb

console.log(getRelativePath('data/orandea/test/aaa/', 'data/orandea/impl/bbb'));
// ../../impl/bbb

console.log(getRelativePath(
  new URL('https://localhost/data/orandea/test/aaa/').pathname,
  new URL('https://localhost/data/orandea/impl/bbb').pathname
))
// ../../impl/bbb

```

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