# relative-path-to-relative-url

> Convert relative file system paths to relative URLs

Latest version **1.0.0** (published 2016-12-19) · ISC license · 0 weekly downloads

## Install

```sh
npm install relative-path-to-relative-url
pnpm add relative-path-to-relative-url
yarn add relative-path-to-relative-url
bun add relative-path-to-relative-url
```

## 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.0 |
| Published | 2016-12-19 |
| First published | 2016-12-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Sebastiaan Deckers |
| Maintainers | seb |
| Keywords | relative, url, path |

## Links

- npm: https://www.npmjs.com/package/relative-path-to-relative-url
- Repository: https://gitlab.com/sebdeckers/relative-path-to-relative-url
- Homepage: https://gitlab.com/sebdeckers/relative-path-to-relative-url#README
- Issues: https://gitlab.com/sebdeckers/relative-path-to-relative-url/issues
- npm.io page: https://npm.io/package/relative-path-to-relative-url

## 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) — 2016-12-19

## README

# relative-path-to-relative-url

Convert relative file system paths to relative URLs.

## Examples

```js
// Unix
relativePathToRelativeUrl('foo/bar')
relativePathToRelativeUrl('/foo/bar')
relativePathToRelativeUrl('./foo/bar')
// -> './foo/bar'

// Windows
relativePathToRelativeUrl('foo\\bar')
relativePathToRelativeUrl('\\foo\\bar')
relativePathToRelativeUrl('.\\foo\\bar')
// -> './foo/bar'
```

## relativePathToRelativeUrl(path)

`path` is a string containing a relative file path.

Returns a string representing a relative URL.

The URL always starts with `./` to make it relative to the current directory.

Respects the path separator of the host environment, typically `/` or `\`.

For example `./foo.js` or `foo.js` or `/foo` will all be returned as `./foo.js` on macOS and Linux, while backslashes will not be converted. Conversely, on Windows `.\foo.js` will be returned as `./foo.js`, while forward slashes will be left unchanged.

## See Also

- [relative-url-to-relative-path](https://www.npmjs.com/package/relative-url-to-relative-path)
- [slash](https://www.npmjs.com/package/slash)

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