Git Product home page Git Product logo

router's People

Contributors

fundon avatar greenkeeperio-bot avatar

Stargazers

 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

Watchers

 avatar  avatar  avatar

router's Issues

Conflict routes

/users/new
/users/:id
/users/nnn

Right behaviour: match /users/:id

About the find method

Hi @fundon,
I was created a Router for Koa based on Trek-Router.

I want to support 405 method not allowed and 501 path not implemented as you can see here but I can't do that with the current result of find method because we don't have any indicator about path was finded or not.

So, if there is any other way to get what I ask. or please add something added to result to be like that;

  const route = TrekRouter.find(method, path)
  const [handler, params, findedPath] = route

  // !handler && findedPath === false => 501 path not implemented.
  // !handler && findedPath === true => 405 method not allowed.

Why not return params as Object?

before

let result = router.find('GET', '/users/233')
// => [handler, params]
// => [()=>{}, [{name: id, value: 233}]]

after

let result = router.find('GET', '/users/233')
// => [handler, params]
// => [()=>{}, {id: 233}]

A bug in find()

      n--
        console.log("before", params);
      params.shift()
        console.log("after", params);
      search = preSearch

I think the params.shift() should be params.pop().
shift() will pop from front, and pop() will pop from back.
In this case, I think it should pop from back.
I use the following case for debug:

  ['GET', '/:prefix/people/:userId/activities/:collection', '/xxx/people/377/activities/333'],
  ['GET', '/:prefix/people/*', '/xxx/people/377/activities'],

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.