Coder Social home page Coder Social logo

raml-path-match's Introduction

RAML Path Match

NPM version Build status Test coverage Greenkeeper badge

Path matching utility based on the RAML spec.

Installation

npm install raml-path-match --save

Usage

You must require the module and call it as a function with options to get the path matching utility back.

const ramlPathMatch = require('raml-path-match')
const utils = require('./utils')

// Initialization Options
const options = {}

// Array<webapi-parser.Parameter>
const parameters = utils.getPathParameters()

// Create a simple path matching instance.
const pathMatch = ramlPathMatch('/{route}', parameters, options)

pathMatch('/test'); //=> { match: '/test', params: { route: 'test' } }

Initialization Options

  • end - When set to false, the route will only match the beginning of paths.
  • strict - When set to true, the route must match exactly without trailing slash.
  • sensitive - When set to true, the route will be case-sensitive.

Routes

The route is a string that can be interpolated with parameters. E.g. /{route}.

Parameters

Parameters in the route string must be defined as an array of webapi-parser Parameter objects.

Optional parameters

Parameters can be optional according to the RAML spec. With optional parameters, /{route} will match just /. When the parameter is optional and not matched, the parameter value will be set to undefined.

Matching the path

The path matching instance will return a function after you give it the route template. This function is used to match the current path against the route template. If the route does not match, false is returned. If it does match, an object will be returned.

{
  match: '/123',
  params: {
    route: 123
  }
}

The above is an example of passing the path /123 to the result of the previous example. Notice that parameters will be automatically sanitized to the native JavaScript types.

Updates

You can merge more parameters into the path after creation using pathMatch.update(params). It'll return a new patch matching function.

License

Apache 2.0

raml-path-match's People

Contributors

blakeembrey avatar greenkeeper[bot] avatar greenkeeperio-bot avatar jcenturion avatar jstoiko avatar postatum avatar svc-scm avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

jstoiko

raml-path-match's Issues

An in-range update of raml-validate is breaking the build 🚨

The dependency raml-validate was updated from 1.2.2 to 1.2.3.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

raml-validate is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Commits

The new version differs by 6 commits.

  • e5c24b5 1.2.3
  • 99c33e4 README
  • bce75fc Migrate istanbul to nyc
  • 697eecf Merge pull request #14 from mulesoft-labs/greenkeeper/initial
  • 7f2f584 chore(package): update lockfile package-lock.json
  • ecbdec2 chore(package): update dependencies

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of raml-sanitize is breaking the build 🚨

The dependency raml-sanitize was updated from 1.3.3 to 1.3.4.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

raml-sanitize is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.