# url-to

> Helper for creating URLs.

Latest version **0.1.3** (published 2018-11-21) · MIT license · 0 weekly downloads

## Install

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

## 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.3 |
| Published | 2018-11-21 |
| First published | 2018-11-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Tamas Pap |
| Maintainers | tamas-pap |

## Links

- npm: https://www.npmjs.com/package/url-to
- Repository: https://github.com/tamaspap/url-to
- Homepage: https://github.com/tamaspap/url-to#readme
- Issues: https://github.com/tamaspap/url-to/issues
- npm.io page: https://npm.io/package/url-to

## Recent versions

- 0.1.3 (latest) — 2018-11-21

## README

What is this?
===============

This is a lightweight helper for working with URLs in javascript.

##How to use it

**1. Get/Set the base url**  
The base url is detected automatically. However, if you want to use a custom base url, use this function as a setter.

    URLTo.base(); -> http://www.example.com
    URLTo.base(http://www.another.com);
    
**2. Create absolute url to a page**

    URLTo.page("about"); -> http://www.example.com/about
    URLTo.page("$1/$2", ["josh", "profile"]) -> http://www.example.com/josh/profile
    URLTo.page("products/:product_id/show", {":product_id": 1234}) -> http://www.example.com/products/1234/show

    
**3. Create absolute url to an API endpoint**

    URLTo.api("users/$1", [1234]); -> http://www.example.com/api/users/1234
    URLTo.api("users/:user_id", {":user_id": 1234}); -> http://www.example.com/api//users/1234
    

**4. Get/Set API endpoint url**

    URLTo.apiBase(); -> http://www.example.com/api
    URLTo.apiBase(http://www.another.com/api);

**5. Build a url**

    URLTo.build("http://www.example.com", "$1/$2", ["josh", "profile"]) -> http://www.example.com/josh/profile
    URLTo.build(http://www.example.com, "products/:product_id/show", {":product_id": 1234}) -> http://www.example.com/products/1234/show    
    
    
    
## Licence

Licensed under the MIT License.

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