https://github.com/proprietary/urip.js
utility library for query strings and URIs
https://github.com/proprietary/urip.js
Last synced: about 1 year ago
JSON representation
utility library for query strings and URIs
- Host: GitHub
- URL: https://github.com/proprietary/urip.js
- Owner: proprietary
- License: apache-2.0
- Created: 2016-01-26T06:05:50.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-01-26T06:13:51.000Z (over 10 years ago)
- Last Synced: 2025-02-10T07:24:35.408Z (over 1 year ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
UriP
----
# Synopsis
Simple JS library to work with query strings and URIs
# Usage
## Build query string
```javascript
const queryObj = {
meaningOfLife: 42,
shit: 'brix',
selectAll: true
};
const queryStr = UriP.serializeQuery(queryObj)
console.log(JSON.stringify(queryStr))
// { meaningOfLife: '42', shit: 'brix', selectAll: 'true' }
```
## Decode URI with query string
```javascript
const complexUri = 'http://search.lycos.com/web/?q=wow+remember+this+shit&keyvol=0084afc23d680d2c5ff1'
const readUri = UriP.read(complexUri)
console.log(JSON.stringify(readUri))
```
## Decode just the query string
```javascript
const uri = '?q=wow+remember+this+shit&keyvol=0084afc23d680d2c5ff1'
const queryObj = UriP.readQuery(uri)
console.log(JSON.stringify(queryObj)) // { q: 'wow remember this shit', keyvol: '0084afc23d680d2c5ff1' }
```
# TODO
## Compile URI with query string
```javascript
const UriP = require('UriP')
var query = {
account: 243922,
listAll: true,
limit: 15
}
var reqUri = UriP.build("http://localhost:3030", query)
console.log(reqUri)
// http://localhost:3030/?account=243922&listAll=true&limit=15
```