Skip to content

Helper to parse url that works seamlessly across Node.js and browser environments

Notifications You must be signed in to change notification settings

vuongtaquoc/url-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

URL Parser

NPM Version NPM Downloads Coverage Status Build Status

Server

Installation

npm install url_parser

Usage

var urlParser = require('url_parser');

urlParser('http://example.com/terms/:termId/posts/:postId', {
	termId: 1,
	postId: 2,
}); // -> http://example.com/terms/1/posts/2
var urlParser = require('url_parser');

urlParser('http://example.com/terms/:termId/posts', {
	termId: 1,
	skip: 5,
	take: 10,
}); // -> http://example.com/terms/1/posts?skip=5&take=10

Client

Installation

bower install url_parser

Usage

In HTML:

<script src="bower_components/url_parser/dist/url-parser.standalone.min.js"></script>

In Javascript:

var url = urlParser('http://example.com/terms/:termId/posts/:postId', {
	termId: 1,
	postId: 2,
});

console.log(url); // -> http://example.com/terms/1/posts/2
var url = urlParser('http://example.com/terms/:termId/posts', {
	termId: 1,
	skip: 5,
	take: 10,
});

console.log(url); // -> http://example.com/terms/1/posts?skip=5&take=10

Tests

$ npm install
$ npm test

License

The MIT License

About

Helper to parse url that works seamlessly across Node.js and browser environments

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published