Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/juliendargelos/open-url-js

Simply manage urls.
https://github.com/juliendargelos/open-url-js

Last synced: 4 days ago
JSON representation

Simply manage urls.

Awesome Lists containing this project

README

        

# Open URL JS 🔍
[![npm version](https://badge.fury.io/js/open-url-js.svg)](https://badge.fury.io/js/open-url-js)
[![Maintainability](https://api.codeclimate.com/v1/badges/27a140e4e8a692f19938/maintainability)](https://codeclimate.com/github/juliendargelos/open-url-js/maintainability)

Simply manage urls.

## Install

```
npm install open-url-js
```

## Usage

```javascript
var Url = require('open-url-js');

var url = new Url('https://www.myapp.com:3000/users/:id/#profile?user[lang]=fr');
url;
// => Url {
// protocol: 'https',
// host: 'www.myapp.com',
// port: 3000,
// path: Pathname ['users', ':id', root: true],
// hash: 'profile',
// parameters: Parameters {
// user: Parameters {
// lang: fr
// }
// }
// }

url.path.id = 4;
url.string;
// => 'https://www.myapp.com:3000/users/4/#profile?user[lang]=fr';

url.parameters = {
lang: 'en',
zone: 'United States'
};
url.string;
// => 'https://www.myapp.com:3000/users/4/#profile?lang=fr&zone=United%20States';
```

{{>main}}