1.0.1 • Published 6 years ago

harbor-sort-address v1.0.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
6 years ago

Build Status License npm Coverage Status

Installation

You can download harbor-sort-address from NPM

$ npm install harbor-sort-address --save

then in your project require harbor-sort-address

const harborAddress = require('harbor-sort-address');

or GitHub

$ git clone https://github.com/leonardofurnielis/harbor-sort-address.git

Guide

const harborAddress = require('harbor-sort-address');

// The addresses should be sorted
const addresses = ['/foo/bar', 'GET /foo', '/foo/bar/baz', 'foo'];

harborAddress(addresses);
// ⇨ ['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
1.0.1

6 years ago