1.12.1 • Published 7 years ago
sandbox-sort-route v1.12.1
Installation
You can download sandbox-sort-route from NPM
$ npm install sandbox-sort-routethen in your project require sandbox-sort-route
const sandboxsort = require('sandbox-sort-route');or GitHub
$ git clone https://github.com/leonardofurnielis1/sandbox-sort-route.gitGuide
const sandboxsort = require('sandbox-sort-route');
// The addresses should be sorted
const addresses = ['/foo/bar', 'GET /foo', '/foo/bar/baz', 'foo'];
sandboxsort(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