risoflora / brookframework

Microframework which helps to develop web Pascal applications.
https://risoflora.github.io/brookframework
GNU Lesser General Public License v2.1
233 stars 54 forks source link

One route cannot be a subset of another route #34

Closed KevinLeeMorris closed 2 years ago

KevinLeeMorris commented 3 years ago

A clear and concise description of what the bug is.

Steps to reproduce:

  1. Create a route with a pattern like this: /apt_tdy_msg_q
  2. Create another route that has a pattern that is a subset of the first pattern, like this: /apt_tdy
  3. Result: Compiler may, or may not complain. If it does not complain...
  4. At run time, Brook Server component will hang on attempt to start

Environment:

Windows Server 2016, Lazarus 2.0.10 FBC 3.2.0,, Brook 5 Framework 5.5.0.0, libsagui 3.3.3.0

I am perhaps in the wrong for using underscores in my patterns. I am a beginner with Brook 5 Framework. I probably shd be using slashes instead.

silvioprog commented 2 years ago

It is matched by regex, so you just need to sort the route register sequence, by registering the route containing the pattern /apt_tdy as the first route.

Alternatively, another way to solve this is using a single router registered by (/apt_tdy_msg_q|/apt_tdy) and get the routed segment via ARoute.Segments[0].

Since it is not a bug, I'm going to close, but please feel absolutely free to send more questions or reopen this issue if you get any bug.