Code Monkey home page Code Monkey logo

Comments (2)

sdogruyol avatar sdogruyol commented on July 22, 2024

Yeah, It doesn't allow two identical routes. We need to document it in a more explicit way

from kemalcr.com.

luislavena avatar luislavena commented on July 22, 2024

Hello, apologies for late reply...

Radix won't allow two identical routes, and those with overlap, the more specific tends to win... I think?

That's actually not accurate. Radix will not allow two equal routes but will allow adding a payload to a shorter one, example:

require "radix"

tree = Radix::Tree(Symbol).new

# this works
tree.add "/foo/bar/baz", :baz
tree.add "/foo/bar", :bar

# not found (no payload at `/foo`)
result = tree.find "/foo"
pp result.found? # => false

result = tree.find "/foo/bar/baz"
pp result.found?  # => true
pp result.payload # => :baz

result = tree.find "/foo/bar"
pp result.found?  # => true
pp result.payload # => :bar

Attempt to add any payload with the same path will result in Radix::Tree::DuplicateError exception.

Hope that helps.

Cheers.

from kemalcr.com.

Related Issues (20)

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.