# urigami

> A tiny library providing parsing and joining urls

Latest version **0.1.0** (published 2021-06-04) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2021-06-04 |
| First published | 2021-06-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Andrey Mikhin |
| Maintainers | qpep3b |
| Keywords | url, uri, parse, join |

## Links

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

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2021-06-04
- 0.0.2 — 2021-06-02
- 0.0.1 — 2021-06-02

## README

# Urigami
[![npm](https://img.shields.io/npm/dt/urigami)](https://www.npmjs.com/package/urigami)
[![bundlephobia](https://badgen.net/bundlephobia/minzip/urigami@latest)](https://bundlephobia.com/result?p=urigami@latest)
[![codecov](https://codecov.io/gh/qpep3b/urigami/branch/master/graph/badge.svg)](https://codecov.io/gh/qpep3b/urigami)

A tiny library providing parsing and joining urls

## Installation
```
npm install urigami
```

## Usage

```js
const {urlJoin, urlParse} = require('urigami')

console.log(urlJoin('http://a.com/some/url', 'aaa/ccc', 'bbb/ddd'))
// output: http://a.com/some/url/aaa/ccc/bbb/ddd/
console.log(urlJoin('http://a.com/some/url', '../../ccc'))
// output: http://a.com/ccc/
console.log(urlJoin('http://a.com', 'aaa/ccc', '/bbb/ddd'))
// output: http://a.com/bbb/ddd/ (because /bbb/ddd is absolute)

urlParse('https://some-url.com:8122/some/internal/location?lorem=ipsum&foo=bar#page-fragment')
/* returns
{
    schema: 'https',
    host: 'some-url.com',
    port: 8122,
    path: '/some/internal/location',
    params: {
        lorem: 'ipsum',
        foo: 'bar',
    },
    fragment: 'page-fragment'
}
*/
```

## Important info about joining urls
* incoming relative url is joined to current path
```js
urlJoin('http://a.com/some/url', 'aaa/ccc')
// returns 'http://a.com/some/url/aaa/ccc/'
```
* incoming absolute path rewrites current
```js
urlJoin('http://a.com', 'aaa/ccc', '/bbb/ddd')
// returns: 'http://a.com/bbb/ddd/'
```
* query params are always merging
```js
urlJoin('http://a.com/some_url?a=b', 'internal?c=d')
// returns: 'http://a.com/some_url/internal/?a=b&c=d'
```
* every incoming fragment rewrites current fragment 
```js
urlJoin('http://a.com/some_url?a=b#existing-fragment', 'internal_path#new-fragment')
// returns: 'http://a.com/some_url/internal_path/?a=b#new-fragment'
```

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