1.12.1 • Published 6 years ago
looney-sort-route v1.12.1
Installation
You can download looney-sort-route
from NPM
$ npm install looney-sort-route
then in your project require looney-sort-route
const looneysort = require('looney-sort-route');
or GitHub
$ git clone https://github.com/leonardofurnielis1/looney-sort-route.git
Guide
const looneysort = require('looney-sort-route');
// The addresses should be sorted
const addresses = ['/foo/bar', 'GET /foo', '/foo/bar/baz', 'foo'];
looneysort(addresses);
// output
['GET /foo', 'foo', '/foo/bar', '/foo/bar/baz'];
Definition of a "route address"
This algorithm, a route address is a string containing:
- An optional HTTP verb prefix, followed by a space, followed by:
- 1 or more path components, where each path component is:
- A forward slash
/
, followed by: - A colon
:
followed by any combination of letters and numbers (a "param"), OR - A star
*
(a "wildcard"), OR - Any combination of letters and numbers
authenticate
- A forward slash
1.12.1
6 years ago