route-match
Advanced tools
Comparing version 0.1.0 to 0.1.3
@@ -1,3 +0,3 @@ | ||
import UrlGenerator from './lib/utility/urlGenerator.js'; | ||
import UrlMatcher from './lib/utility/urlMatcher.js'; | ||
import PathGenerator from './lib/utility/pathGenerator.js'; | ||
import PathMatcher from './lib/utility/pathMatcher.js'; | ||
import RouteCollection from './lib/collection/routeCollection.js'; | ||
@@ -9,4 +9,4 @@ import Route from './lib/model/route.js'; | ||
RouteCollection: RouteCollection, | ||
UrlMatcher: UrlMatcher, | ||
UrlGenerator: UrlGenerator | ||
PathMatcher: PathMatcher, | ||
PathGenerator: PathGenerator | ||
}; |
{ | ||
"name": "route-match", | ||
"version": "0.1.0", | ||
"version": "0.1.3", | ||
"description": "Can be used to match and generate url paths agains predefined patterns. Can be used when applying routing in javascript client-side and backend applications. Uses ECMA6 javascript standard.", | ||
@@ -26,9 +26,9 @@ "main": "index.js", | ||
"type": "MIT", | ||
"url": "https://github.com/gnoesiboe/react-url-matcher/blob/master/LICENSE-MIT" | ||
"url": "https://github.com/gnoesiboe/route-match/blob/master/LICENSE-MIT" | ||
} | ||
], | ||
"bugs": { | ||
"url": "https://github.com/gnoesiboe/route-matcher/issues" | ||
"url": "https://github.com/gnoesiboe/route-match/issues" | ||
}, | ||
"homepage": "https://github.com/gnoesiboe/route-matcher#readme", | ||
"homepage": "https://github.com/gnoesiboe/route-match#readme", | ||
"devDependencies": { | ||
@@ -35,0 +35,0 @@ "chai": "^3.4.0", |
@@ -13,6 +13,8 @@ # route-match | ||
When using a client that does not support ECMA6, please use a javascript compiler like [Babel](http://babeljs.io/) to compile the code to a readable format. | ||
### Generating URLs | ||
```javascript | ||
import { Route, RouteCollection, UrlMatcher } from 'url-matcher'; | ||
import { Route, RouteCollection, PathGenerator } from 'route-match'; | ||
@@ -23,5 +25,5 @@ var myRouteCollection = new RouteCollection([ | ||
var myUrlGenerator = new UrlGenerator(myRouteCollection); | ||
var myPathGenerator = new PathGenerator(myRouteCollection); | ||
console.log(myUrlGenerator.generate('user_detail', { id: 10 })); // result: /user/10 | ||
console.log(myPathGenerator.generate('user_detail', { id: 10 })); // result: /user/10 | ||
``` | ||
@@ -37,3 +39,3 @@ | ||
```javascript | ||
import { Route, RouteCollection, UrlMatcher } from 'url-matcher'; | ||
import { Route, RouteCollection, PathMatcher } from 'route-match'; | ||
@@ -44,5 +46,5 @@ var myRouteCollection = new RouteCollection([ | ||
var myUrlMatcher = new UrlMatcher(myRouteCollection); | ||
var myPathMatcher = new PathMatcher(myRouteCollection); | ||
console.log(myUrlGenerator.match('/user/10'); // result: instance of RouteMatch containing route name, payload and parameters | ||
console.log(myPathGenerator.match('/user/10'); // result: instance of RouteMatch containing route name, payload and parameters | ||
``` | ||
@@ -49,0 +51,0 @@ |
@@ -189,9 +189,9 @@ import { assert } from 'chai'; | ||
describe('UrlMatcher', function () { | ||
describe('PathMatcher', function () { | ||
describe('Instantiation', function () { | ||
it('Throws an Error when instantiated without route collection', function () { | ||
try { | ||
new library.UrlMatcher(); | ||
new library.PathMatcher(); | ||
assert.nogOk('UrlGenerator could be instantiated without route collection'); | ||
assert.notOk('PathGenerator could be instantiated without route collection'); | ||
} catch (error) { | ||
@@ -207,5 +207,5 @@ assert.ok(error instanceof InvalidRouteCollectionError); | ||
var myUrlMatcher = new library.UrlMatcher(myRouteCollection); | ||
var myPathMatcher = new library.PathMatcher(myRouteCollection); | ||
assert.ok(myUrlMatcher instanceof library.UrlMatcher); | ||
assert.ok(myPathMatcher instanceof library.PathMatcher); | ||
}); | ||
@@ -220,5 +220,5 @@ }); | ||
var myUrlMatcher = new library.UrlMatcher(myRouteCollection); | ||
var myPathMatcher = new library.PathMatcher(myRouteCollection); | ||
assert.ok(myUrlMatcher.match('/some-other-route') === null); | ||
assert.ok(myPathMatcher.match('/some-other-route') === null); | ||
}); | ||
@@ -231,5 +231,5 @@ | ||
var myUrlMatcher = new library.UrlMatcher(myRouteCollection); | ||
var myPathMatcher = new library.PathMatcher(myRouteCollection); | ||
assert.ok(myUrlMatcher.match('/some-path') instanceof RouteMatch); | ||
assert.ok(myPathMatcher.match('/some-path') instanceof RouteMatch); | ||
}); | ||
@@ -242,5 +242,5 @@ | ||
var myUrlMatcher = new library.UrlMatcher(myRouteCollection); | ||
var myPathMatcher = new library.PathMatcher(myRouteCollection); | ||
var match = myUrlMatcher.match('/user/10'); | ||
var match = myPathMatcher.match('/user/10'); | ||
@@ -257,6 +257,6 @@ assert.ok(match instanceof RouteMatch); | ||
var myUrlMatcher = new library.UrlMatcher(myRouteCollection); | ||
var myPathMatcher = new library.PathMatcher(myRouteCollection); | ||
assert.ok(myUrlMatcher.match('/user/12') instanceof RouteMatch); | ||
assert.ok(myUrlMatcher.match('/user/test') === null); | ||
assert.ok(myPathMatcher.match('/user/12') instanceof RouteMatch); | ||
assert.ok(myPathMatcher.match('/user/test') === null); | ||
}); | ||
@@ -269,5 +269,5 @@ | ||
var myUrlMatcher = new library.UrlMatcher(myRouteCollection); | ||
var myPathMatcher = new library.PathMatcher(myRouteCollection); | ||
var match = myUrlMatcher.match('/user/12?test=10&test2=water'); | ||
var match = myPathMatcher.match('/user/12?test=10&test2=water'); | ||
@@ -293,5 +293,5 @@ assert.ok(match instanceof RouteMatch); | ||
var myUrlMatcher = new library.UrlMatcher(myRouteCollection); | ||
var myPathMatcher = new library.PathMatcher(myRouteCollection); | ||
var match = myUrlMatcher.match('/'); | ||
var match = myPathMatcher.match('/'); | ||
@@ -307,7 +307,7 @@ assert.ok(typeof match.routePayload['_controller'] !== 'undefined'); | ||
describe('UrlGenerator', function () { | ||
describe('PathGenerator', function () { | ||
describe('Instantiation', function () { | ||
it('Throws an error when instantiated without a route collection', function () { | ||
try { | ||
new library.UrlGenerator(); | ||
new library.PathGenerator(); | ||
@@ -321,5 +321,5 @@ assert.notOk('Should not get to this point'); | ||
it('Allows instantiation with a route collection', function () { | ||
var myUrlGenerator = new library.UrlGenerator(new library.RouteCollection()); | ||
var myPathGenerator = new library.PathGenerator(new library.RouteCollection()); | ||
assert.ok(myUrlGenerator instanceof library.UrlGenerator); | ||
assert.ok(myPathGenerator instanceof library.PathGenerator); | ||
}); | ||
@@ -332,6 +332,6 @@ }); | ||
var myUrlGenerator = new library.UrlGenerator(myRouteCollection); | ||
var myPathGenerator = new library.PathGenerator(myRouteCollection); | ||
try { | ||
myUrlGenerator.generate('non_existant_route'); | ||
myPathGenerator.generate('non_existant_route'); | ||
@@ -349,5 +349,5 @@ assert.notOk('Should not get to this point'); | ||
var myUrlGenerator = new library.UrlGenerator(myRouteCollection); | ||
var myPathGenerator = new library.PathGenerator(myRouteCollection); | ||
assert.ok(myUrlGenerator.generate('home') === '/'); | ||
assert.ok(myPathGenerator.generate('home') === '/'); | ||
}); | ||
@@ -360,5 +360,5 @@ | ||
var myUrlGenerator = new library.UrlGenerator(myRouteCollection); | ||
var myPathGenerator = new library.PathGenerator(myRouteCollection); | ||
var generatedPath = myUrlGenerator.generate('user_detail', { | ||
var generatedPath = myPathGenerator.generate('user_detail', { | ||
id: 10 | ||
@@ -375,6 +375,6 @@ }); | ||
var myUrlGenerator = new library.UrlGenerator(myRouteCollection); | ||
var myPathGenerator = new library.PathGenerator(myRouteCollection); | ||
try { | ||
myUrlGenerator.generate('user_detail', { | ||
myPathGenerator.generate('user_detail', { | ||
id: 'not_allowed_value' | ||
@@ -392,5 +392,5 @@ }); | ||
var myUrlGenerator = new library.UrlGenerator(myRouteCollection); | ||
var myPathGenerator = new library.PathGenerator(myRouteCollection); | ||
var generatedUrl = myUrlGenerator.generate('home', { | ||
var generatedUrl = myPathGenerator.generate('home', { | ||
test: 'other' | ||
@@ -397,0 +397,0 @@ }); |
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
31847
1
1
58