# @coolgk/url

> a simple function for parsing parameters in a url

Latest version **2.0.6** (published 2018-02-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install @coolgk/url
pnpm add @coolgk/url
yarn add @coolgk/url
bun add @coolgk/url
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.0.6 |
| Published | 2018-02-21 |
| First published | 2018-01-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Daniel Gong |
| Maintainers | coolgk |
| Keywords | url, parser, typescript |

## Links

- npm: https://www.npmjs.com/package/@coolgk/url
- Repository: https://github.com/coolgk/node-utils
- Issues: https://github.com/coolgk/node-utils/issues
- npm.io page: https://npm.io/package/@coolgk/url

## 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

- 2.0.6 (latest) — 2018-02-21
- 2.0.5 — 2018-01-29
- 2.0.4 — 2018-01-29
- 2.0.3 — 2018-01-25
- 2.0.2 — 2018-01-25
- 2.0.1 — 2018-01-24
- 2.0.0 — 2018-01-20
- 1.1.4 — 2018-01-17
- 1.1.3 — 2018-01-17
- 1.1.2 — 2018-01-16
- 1.1.1 — 2018-01-16
- 1.1.0 — 2018-01-16
- 1.0.9 — 2018-01-14
- 1.0.8 — 2018-01-13
- 1.0.6 — 2018-01-12
- … 3 more at https://npm.io/package/@coolgk/url/versions

## README

## @coolgk/url
a javascript / typescript module

`npm install @coolgk/url`

a simple function for parsing parameters in a url

Report bugs here: [https://github.com/coolgk/node-utils/issues](https://github.com/coolgk/node-utils/issues)
## Examples
```javascript
import { getParams } from '@coolgk/url';
// OR
// const { getParams } = require('@coolgk/url');

const url = '/123';
const pattern = '/:id';

console.log(getParams(url, pattern)); // { id: '123' }

const url2 = '/123/abc/456';
const pattern2 = '/:id/abc/:value';

console.log(getParams(url2, pattern2)); // { id: '123', value: '456' }

const url3 = '/123/456';
const pattern3 = ':id/:value';

console.log(getParams(url3, pattern3)); // { id: '123', value: '456' }

```
<a name="getParams"></a>

## getParams(url, pattern) ⇒ <code>object</code>
a simple function to get params in a url e.g. with url: user/123, pattern: user/:id returns {id: 123}

**Kind**: global function  
**Returns**: <code>object</code> - - e.g. {userid: 123}  

| Param | Type | Description |
| --- | --- | --- |
| url | <code>string</code> | url after the domain name e.g. http://abc.com/user/:id url should be /user/:id |
| pattern | <code>string</code> | e.g. /:userid/:name |

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